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: - https://github.com/microsoft/kiota-java/actions/runs/15538363819/job/43742832455?pr=1932 - https://github.com/microsoft/kiota-java/pull/1932 - https://github.com/Azure/azure-sdk-for-java/pull/44968

Comment From: cowtowncoder

I don't know what could be done here, although this seems odd: FastDoubleParser (https://mvnrepository.com/artifact/ch.randelshofer/fastdoubleparser/1.0.90) is included as shaded component, and it has not dependencies of its own.

So is there any chance Android SDK tooling might have an issue to fix? (or maybe this works with certain version of ASDK).

Also worth checking if Jackson 2.19.0 is any different in this regard (none of changes seems relevant but just in case).

Comment From: cowtowncoder

Ok. Perhaps this is due to FastDoubleParser version upgrade included in 2.18.1. If so, 2.18.0 might actually work, as it still depends on 1.0.1 instead of 1.0.90

But I really hope this is not it because... that'd be difficult thing to reconcile wrt compatibility.

/cc @pjfanning .

Comment From: pjfanning

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?

Comment From: baywet

@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)

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

kotlin lint { checkAllWarnings = true }

  1. run gradle build

Comment From: cowtowncoder

Looks like java.lang.foreign was officially added in JDK 22 (although preview in 21)

So one work-around could be to just drop JDK-specific optimized classes under META-INF/versions/22/ in jackson-core jar. Or perhaps both 21 and 22 .

This assuming nothing else works: ideally of course Android tooling would ignore classes for JDKs they are not compatible with.

Comment From: cowtowncoder

Thank you @baywet . I don't have Android dev setup myself, but this should be helpful for others (or possibly myself eventually).

Comment From: pjfanning

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

Comment From: baywet

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.

Comment From: cowtowncoder

@baywet Interesting. If so, maybe it's FDP 1.0.0 to 1.0.1 that triggered the issue, not 1.0.1 -> 1.0.90. In that case, 2.17.3 would have same issue. If so, we'd want to patch 2.17 as well as 2.18.

Comment From: pjfanning

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

Comment From: baywet

@pjfanning thanks for joining this thread. Although I'm far from a Java experienced dev (or Android for that matter), from reading the documentation I agree that any class making use of Foreign should only be "present" from java 19 and up (in preview), which seems to have been made stable by version 22.

These versioned classes appear in META-INF/versions/11 where 11 is the Java version

Consequently this seems incorrect and should be corrected. Ideally to 22.

Comment From: cowtowncoder

One reason it'd be important to resolve this for 2.18 is that as per JSTEP-13 (LTS versions for Jackson):

https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-13

2.18 is planned to be the first such version (for various reasons). So while patching 2.17 would be good, 2.18 is more of essential.

Comment From: alzimmermsft

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.

Comment From: pjfanning

@pjfanning thanks for joining this thread. Although I'm far from a Java experienced dev (or Android for that matter), from reading the documentation I agree that any class making use of Foreign should only be "present" from java 19 and up (in preview), which seems to have been made stable by version 22.

These versioned classes appear in META-INF/versions/11 where 11 is the Java version

Consequently this seems incorrect and should be corrected. Ideally to 22.

I'm only providing an example directory for people who don't want to read the JEP.

Comment From: cowtowncoder

These versioned classes appear in META-INF/versions/11 where 11 is the Java version Consequently this seems incorrect and should be corrected. Ideally to 22.

I think @pjfanning meant that JDK-specific implementation classes are included starting with 11. But references to java.lang.foreign hopefully only from 22. I agree that if JDK-11 version had dependency that'd be wrong

Comment From: cowtowncoder

@alzimmermsft yes, I would think tooling should ignore classes for JDKs not supported.

Comment From: pjfanning

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.

Comment From: pjfanning

@cowtowncoder I created #1447

Comment From: baywet

Thanks everyone for all this great information! I took the time to: 1. decompress the jar file (2.18) 2. decompile the FastDoubleSwar class files (there are variants for 11, 17, 21 and 22)

The variant for version 22 is the only version that has a reference to something in java.lang.Foreign (MemorySegment and ValueLayout.OfLong) which would indicate that the Android SDK is indeed taking that version, when it should take the version in the "main" package when targeting java8, the 11 variant when targeting java11, and the 17 variant when targeting java17. (all of that depending on the target/min SDK settings and the source compatibility options)

Comment From: pjfanning

@baywet the issue is here:

> Task :components:authentication:azure:android:lintReportDebug
Wrote HTML report to file:///home/runner/work/kiota-java/kiota-java/components/authentication/azure/android/build/reports/lint-results-debug.html
Lint found 1 error. First failure:
Error: /home/runner/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.18.3/78f80c259268200e588aa204dd97ecf09b76916e/jackson-core-2.18.3.jar: 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. [InvalidPackage]

Can't you find out who is behind the components:authentication:azure:android:lintReportDebug and ask them what's up?

Comment From: baywet

For this components:authentication:azure:android:lintReportDebug I (my team) owns that part components:authentication:azure:android: as an integration test (to catch any regression from changes which might affect android users). And this in turns rely on standard android SDK for this task lintReportDebug.

Comment From: baywet

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

Comment From: cowtowncoder

Thank you everyone for your help! If this turns out to be a tooling thing that can be fixed, that'd be great.

FWTW, we have had quite a few issues wrt (lack of) support for Multi-Release jars: esp. with Gradle. Which probably doesn't help either, given Gradle's ubiquity as Android build tool.

Comment From: baywet

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.

Comment From: cowtowncoder

Merged https://github.com/FasterXML/jackson-core/pull/1447 so jackson-core snapshot build (2.18.5-SNAPSHOT) should work better. Would be great if someone could verify -- will merge forward to 2.19.1-SNAPHOT now, assuming fix is good.