-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-Release JAR is not recognized as such #2495
Comments
Hi there... |
Solved for me by recompile with java 22 |
Steps to reproduce this issue
Expected: WorkaroundsAs a workaround, do one of the following:
See also |
It seems this is related to the moditect-maven-plugin. For Gson and json-schema-validator it looks like this issue started occurring when they updated moditect-maven-plugin to 1.2.0.Final (for Gson 2.10.1 → 2.11.0; for json-schema-validator 1.4.0 → 1.4.1). I am not completely sure where exactly the issue is within jdt.core and if there are multiple classes affected (please double check!), but I could at least find one location: Lines 83 to 85 in ed787f5
Here is an example for testing this: public static void main(String[] args) throws Exception {
System.out.println(getModuleName("gson-2.10.1.jar"));
System.out.println(getModuleName("gson-2.11.0.jar"));
System.out.println(getModuleName("json-schema-validator-1.4.0.jar"));
System.out.println(getModuleName("json-schema-validator-1.4.1.jar"));
}
static String getModuleName(String path) throws Exception {
AccessRuleSet accessRuleSet = new AccessRuleSet(new AccessRule[0], AccessRestriction.LIBRARY, "test");
ClasspathJar classpathJar = new ClasspathMultiReleaseJar(new ZipFile(path), accessRuleSet, true, "9");
// Initialize module information
new ModulePathEntry(new Path(path), classpathJar);
return new String(classpathJar.getModule().name());
} (tested with The code in It is not completely clear if that directory entry is required. The JAR specification talks about the "directory" but it does not explicitly say that this directory must exist as ZIP entry.
There seems to be some duplication regarding multi-release handling in jdt.core, at least these classes all have logic for
Confusingly though And I think so far I also haven't seen any |
As side note: This only affects JDT within the Eclipse IDE. The ECJ batch compiler does not properly support modular multi-release JARs at all, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=577790 / #2778 and #61. |
Probably related: Bugzilla – Bug 534624 Support module-info.java in multi-release JAR files I have the same problem AndreasWBartels described. |
See also FasterXML/jackson-databind#4727 for the complaints in Jackson, which is also related to Moditech. The conclusion there is that it's an Eclipse issue, but they have worked around it by downgrading their Moditech version while waiting for an Eclipse-side fix. |
Recently, I update com.google.code.gson:gson to version 2.11.0 from version 2.10.1.
The project use module-info.java and use "requires com.google.gson;"
gson-2.11.0.jar is a Multi-Release JAR and the module declaration is at META-INF/versions/9/module-info.class
I open an issue and it got the full details.
Also included in that issue a small project to demonstrate the problem.(https://github.com/google/gson/files/15412480/ModuleTest.zip)
When using pure maven build "mvn clean test" it is compiled successfully.
Also I can run it using "mvn compile exec:java -Dexec.mainClass="main.Main"" .
I use:
M2E Maven Integration for Eclipse Core 2.6.0.20240220-1109
Eclipse 2024-03 (4.31)
Java openjdk version "22.0.1" 2024-04-16
Thanks in advance for any response.
The text was updated successfully, but these errors were encountered: