Skip to content
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

JDK compatibility issues with jackson-core 2.14 and later due to Multi-Release (MR) jars #1210

Open
techwhizbang opened this issue Feb 6, 2024 · 4 comments

Comments

@techwhizbang
Copy link

techwhizbang commented Feb 6, 2024

The time that the jackson-core library switched from using its own copy of the fasterdoubleparser code to the actual library this can cause JDK incompatibilities. The problem manifests itself if you take any newer version of the jackson-core libraries 2.14 or better and you need to do any type of dependency shading. If you do - the fasterdoubleparser uses a technique of putting all the class files across different JDK's well beyond the advertised JDK8 compatibility (https://github.com/FasterXML/jackson-core?tab=readme-ov-file#jdk) via the Maven assembly plugin (https://github.com/wrandelshofer/FastDoubleParser/blob/main/fastdoubleparser/src/assembly/mrjar.xml).

When shading you end up getting all the class files for all thefasterdoubleparser supported JDK's and if you aren't using the highest JDK version possible you will run into problems like this:

java.lang.IllegalArgumentException: Unsupported class file major version 63
at shadow.org.objectweb.asm.ClassReader.(ClassReader.java:199)
at shadow.org.objectweb.asm.ClassReader.(ClassReader.java:180)
at shadow.org.objectweb.asm.ClassReader.(ClassReader.java:166)
at shadow.org.objectweb.asm.ClassReader.(ClassReader.java:287)

For example I am using JDK17 and the Gradle Shadow plugin. The ASM library aborts when it finds a class file that isn't inline with the JDK you are running.

This is easily reproducible if you use the Gradle Shadow plugin or the Maven Shade plugin and use JDK17 and include the jackson-core 2.15.2 as a dependency for example.

@pjfanning
Copy link
Member

Please read https://openjdk.org/jeps/238 -- MR Jars are an important feature of Java.

Please raise this with Gradle and Gradle Shadow plugin. Try upgrading to latest Gradle and Gradle plugin.

I use Gradle and it works fine with jackson-core.

@techwhizbang
Copy link
Author

techwhizbang commented Feb 6, 2024

I'm using Gradle 7.x and Gradle 8.x. It works fine with Gradle and in the context of a standard build.

The problem arises if you attempt to use the newer jackson-core library with the dependency on fasterdoubleparser in a shadow jar with either the Maven shade or Gradle shadow plugin.

I suppose your point is that the shadow plugins and libraries may need to be updated to work in harmony with https://openjdk.org/jeps/238.

@GedMarc
Copy link

GedMarc commented Feb 7, 2024

Not quite, The classes are compiled in JDK 19 and you are building with JDK 17.
Version 63 = JDK 19

Also look at updating the ASM library dependency to support JDK 19, or 21 preferred, 9.6 I think it is

@cowtowncoder cowtowncoder changed the title JDK incompatibility issues with jackson-core 2.14 or better JDK compatibility issues with jackson-core 2.14 or better due to Multi-Release (MR) jars Mar 28, 2024
@cowtowncoder
Copy link
Member

I think it is unfortunate there are issues wrt shading, MR jars. But I am not quite sure what could be done here to help?

Leaving issue open so anyone with problems can find it, and maybe we get some ideas for versions of tools that help, and perhaps workarounds.

@cowtowncoder cowtowncoder changed the title JDK compatibility issues with jackson-core 2.14 or better due to Multi-Release (MR) jars JDK compatibility issues with jackson-core 2.14 and later due to Multi-Release (MR) jars May 1, 2024
serpro69 added a commit to serpro69/kotlin-faker that referenced this issue Sep 10, 2024
Fixes java.lang.IllegalArgumentException: Unsupported class file major version 65

Gradle :core:shadowJar task throws the above exception with jackson > 2.16.0
due to FasterXML/jackson-core#1210
serpro69 added a commit to serpro69/kotlin-faker that referenced this issue Sep 10, 2024
Fixes java.lang.IllegalArgumentException: Unsupported class file major version 65

Gradle :core:shadowJar task throws the above exception with jackson > 2.16.0
due to FasterXML/jackson-core#1210
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants