Skip to content

Different compilation behavior using a built-from-source jar vs maven central jar #4755

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

Closed
brownp2k opened this issue Oct 18, 2024 · 8 comments
Labels
to-evaluate Issue that has been received but not yet evaluated

Comments

@brownp2k
Copy link

Describe your Issue

We have a requirement to use our own built-from-source jars. When building jackson-databind 2.18.0 from source and using the resulting jar in our project, our own project compilation fails because jackson-databind enables Java 11 preview features. However, our own project compilation succeeds when using the jackson-databind 2.18.0 jar from maven central.

The error we see using the built-from-source jar:
error: classfile for C:\Users\<user>\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.18.0\3ddbe54c9c69b46e8f56fd63d968d6b311ce5be6\jackson-databind-2.18.0.jar(/com/fasterxml/jackson/databind/node/ArrayNode.class) uses preview features of Java SE 11.

I have so far been unable to determine the difference with the jar we build is vs what was officially published, but there is definitely a difference in behavior. Does anyone have insight into what would cause this behavioral difference?

@brownp2k brownp2k added the to-evaluate Issue that has been received but not yet evaluated label Oct 18, 2024
@brownp2k brownp2k changed the title Different compilation behavior using a built-from-source jackson-databind jar vs maven central jar Different compilation behavior using a built-from-source jar vs maven central jar Oct 18, 2024
@brownp2k
Copy link
Author

Ah, the maven central jar was built with Java 8. I was building jackson-databind with Java 11 and switching to build with Java 8 resolved the issue I was seeing.

In version 2.15.2 the --enable-preview flag was only applied to Java 14. Starting in 2.16.0 the flag is now applied to Java 11.

@yawkat
Copy link
Member

yawkat commented Oct 18, 2024

wild to think that my code is used to simulate laser weapons 😄

@cowtowncoder
Copy link
Member

Hmmh. So preview feature enabling must be from pom.xml?
Anyway glad you got it working: yes, we try to make sure to build jars with JDK 8 since that is the baseline (well for annotations Java 6 in theory), for Jackson 2.x.

@brownp2k
Copy link
Author

Hmmh. So preview feature enabling must be from pom.xml?

Yep, this line:

<arg>--enable-preview</arg>

Anyway glad you got it working: yes, we try to make sure to build jars with JDK 8 since that is the baseline (well for annotations Java 6 in theory), for Jackson 2.x.

Well, as a reference point, we were building 2.15.2 with Java 11, and running our application with Java 11 and everything worked just fine. The pom.xml for 2.15.2 was specifying Java 14 for "--enable-preview", which changed to Java 11 for 2.16.0.

Building with 8 is fine with me and it works well, but I was just caught off guard when it quit working on me. After inspecting the maven central jar manifest I realized the difference was Java 8 vs 11.

@cowtowncoder
Copy link
Member

Oh. I don't think we should have --enable-preview at all really. Will see if I can remove it.

@pjfanning
Copy link
Member

@cowtowncoder there is 1 test that relies on it - I ran this a few days ago so I don't have its name

It might be useful to move that test to a separate module

@cowtowncoder
Copy link
Member

@pjfanning I am not sure I see that, see #4760 which seems to pass. Same running locally.

@cowtowncoder
Copy link
Member

Removed --enable-preview from JDK 11 profile; things seem to work still. Thank you @brownp2k for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to-evaluate Issue that has been received but not yet evaluated
Projects
None yet
Development

No branches or pull requests

4 participants