jackson-core: Invalid package reference to "java.lang.foreign" from `com.fasterxml.jackson.core:jackson-core` (from `FastDoubleParser`) [Android]

Adding v2.18.3 in an android project leads to the following error message when running gradle build.

Error: Invalid package reference in com.fasterxml.jackson.core:jackson-core; not included in Android: java.lang.foreign. Referenced from com.fasterxml.jackson.core.internal.shaded.fdp.v2_18_3.FastDoubleSwar

No workaround is known, besides downgrading the dependency.

More context:

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 33 (22 by maintainers)

Most upvoted comments

thanks! I can confirm the build was successful with 2.18.5-SNAPSHOT When can we expect a non-snapshot release with that fix?

Thanks! I’ll revert to our Azure friends so they upgrade the dependency on their end. It was great to work with this community! Extra efficient investigation and prompt resolution!

On the Android bug front I’ve receive notifications that they have triaged it to the team owning the linting tool.

yep, I really appreciated the help and the quick turnaround on this issue. This is clearly an issue somewhere within the linting tool, as when I disable linting, the rule, or add a suppression for this instance, things start working again. Hopefully our friends at Google take it from here and give us a fix in the Android SDK.

And I just filed an issue with the android SDK folks. I would have categorized it directly to the lint tool, but don’t have permissions to do so. https://issuetracker.google.com/issues/423632847

Wanted to reply here as I’m owning the issue in azure-sdk-for-java, where the release of our azure-core library using Jackson 2.18.3 resulted in this issue, and this issue will have more eyes and traction.

Could this be considered an issue in the Android application being built? I could be reading this chart wrong, Android doesn’t appear to have support for anything Java 22 (or even Java 21): https://developer.android.com/build/jdks#compileSdk

Shouldn’t this be on the Android build to prevent inclusion of multi-release code from above the supported Java version? Ex, since Android 26 is used in the application, anything above Java 8 should be excluded.

@alzimmermsft please read the JEP link. All Java based applications should ignore META-INF/versions/xyz classes if they don’t explicitly support them. For non-Android JREs, they ignore forward versions. So JRE for Java 17 doesn’t crash if a jar has META-INF/versions/21 classes (as an example). @baywet’s build is using something that doesn’t work with JEP-238. I’d prefer if you contacted the people who provide @baywet’s build tooling to ask them why they can’t work JEP-238 which is live since Java 9.

Wanted to reply here as I’m owning the issue in azure-sdk-for-java, where the release of our azure-core library using Jackson 2.18.3 resulted in this issue, and this issue will have more eyes and traction.

Could this be considered an issue in the Android application being built? I could be reading this chart wrong, Android doesn’t appear to have support for anything Java 22 (or even Java 21): https://developer.android.com/build/jdks#compileSdk

Shouldn’t this be on the Android build to prevent inclusion of multi-release code from above the supported Java version? Ex, since Android 26 is used in the application, anything above Java 8 should be excluded.

@cowtowncoder the Java 21 version of FastDoubleSwar does not use java.lang.foreign.

After iterating over all the recent versions I can confirm that 2.18.0 is the FIRST version this starts failing. And that 2.19.0 is also failing.

I’m not against blocking the Java 22 classes from jackson-core. We’ve had build time filtering of the FastDoubleParser versioned classes before.

@cowtowncoder thanks for the quick reply!

Here is the full repo (in android studio):

  1. create a new project (empty activity, api level 26)

  2. add the following dependencies in /app/build.gradle (.kts if kotlin was selected)

    implementation("com.fasterxml.jackson.core:jackson-core:2.19.0")
    
  3. Add the following option above the dependencies section

    lint {
         checkAllWarnings = true
     }
    
  4. run gradle build

FastDoubleSwar is multi-release jar class. That is, a class where the jar has different versions of the class targeted at different Java versions. These versioned classes appear in META-INF/versions/11 where 11 is the Java version. https://openjdk.org/jeps/238

java.lang.foreign is pretty new so FastDoubleSwar would only be set up to use this package for the latest Java versions (eg Java 21).

Whatever Android set up is being use by @baywet seems not to be able to handle JEP 238.

Is this not Android’s problem? The JEP is not new. If they want to use Java classes, shouldn’t they be up to date with the JEPs?