-
Notifications
You must be signed in to change notification settings - Fork 21
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
package-info.class files inside org.eclipse.parsson:jakarta.json are compiled with the wrong Java version #73
Comments
That happens with the whole bundle, not only package-info.class Parsson takes the java sources and compiles everything for version 53. For example with the class JsonNumber:
I think that is unexpected. It should compile for release 8 |
For the jars on Maven Central, only
|
I have downloaded also the jakarta.json-api-2.1.1.jar and it has the same issue.
Parsson seems to be doing it well. Here it compiles with -release 8
One of the paths in the sourcespath is
Maybe this is a bug in the maven-compiler-plugin. |
I have created a simple reproducer. It seems it is an issue in the JDK, because we see the maven-compiler-plugin sets the arguments correctly. The reproducer is:
|
I found a workaround for the maven-compiler-plugin bug. Set
|
Thank you for your finding, I am going to use it. |
…compiled with the wrong Java version eclipse-ee4j#73 Signed-off-by: Jorge Bescos Gascon <[email protected]>
Please be aware that 10b8d10 generates JAR files with mixed bytecode versions in the unversioned space. The way to fix this is to turn JARs into Multi Release JARs https://docs.oracle.com/javase/10/docs/specs/jar/jar.html#multi-release-jar-files
|
No. The cause is "a bug" in maven-compiler-plugin, or better two issues there:
|
Well, no. Actually, it depends. Is Parsson's baseline supposed to be Java 8?
The "bug" in Maven is the how_to_solve it, I'm asking the what_it_is_supposed_to be. |
The README does not state what's the Java baseline for the project, nor any of the direct links found in the README. At the moment the only way to tell is by looking at Lines 192 to 214 in 10b8d10
One may infer Java 8 given that json-p 2.x targets JakartaEE 9. But Parsson does not state explicitly (README or project site (at least on the overview page and releases)) which version of json-p is implemented unless one looks again inside the pom.xml file Line 99 in 10b8d10
|
module-info.class seems to be ignored in runtime by jre 8, this is why it is included in the jar compiled with release 9. There are no errors with this behavior. Let me know if you have any reason to modify this. We use multirelease when we want to modify an existing class for different jre versions. |
It depends on the tool. Maven & Gradle enforcers will fail the build if the baseline is set to Java 8 because Yes, a Java 8 VM will ignore
That is but one of the uses of MR-JARs. Another is to "hide" classes from older VMs. |
Latest spec https://docs.oracle.com/en/java/javase/19/docs/specs/jar/jar.html has this to say: Modular multi-release JAR files A modular multi-release JAR file is a multi-release JAR file that has a module descriptor, module-info.class, in the top-level directory (as for a modular JAR file), or directly in a versioned directory. A public or protected class in a non-exported package (that is not declared as exported in the module descriptor) need not preside over a class of the same fully qualified name and access modifier whose class file is present under the top-level directory. 👇 this is the important bit Any versioned module descriptor that presides over a lesser versioned module descriptor or that at the top-level, M say, must be identical to M, with two exceptions:
👇 this one as well |
…compiled with the wrong Java version #73 Signed-off-by: Jorge Bescos Gascon <[email protected]>
Jars of org.eclipse.parsson:jakarta.json are compiled for Java version 8 (class version 52). However, the
package-info.class
files inside versions1.0.1
,1.0.2
, and1.1.1
are actually compiled for Java version 9 (class version 53).This is causing issues with IBM Websphere Application Server. It scans the jars before loading them and refuses to load them because they have classes with version>52:
A workaround is using
jakarta.json:jakarta.json-api
andorg.eclipse.parsson:parsson
instead oforg.eclipse.parsson:jakarta.json
The text was updated successfully, but these errors were encountered: