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

IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation on Android 4.3.1 and Jackson 2.12.0 #3123

Closed
johnjohndoe opened this issue Apr 16, 2021 · 9 comments
Labels
android Issues related to use on Android platform will-not-fix Closed as either non-issue or something not planned to be worked on

Comments

@johnjohndoe
Copy link
Contributor

johnjohndoe commented Apr 16, 2021

Describe the bug

  • I discovered an IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation when I run this Android app in the following environment:

    • Android emulator, Nexus 5X, Intel x86 Atom, system-images;android-18;google_apis;x86, revision: 6
    • Android 4.3.1 (API level 18, Jelly Bean)
    • no Google Play Services installed
    • crash occured in DEBUG build, RELEASE build not tested yet
    • com.fasterxml.jackson.core:jackson-databind:2.12.0

Version information

  • com.fasterxml.jackson.core:jackson-databind:2.12.0 - 2.12.3

To Reproduce

  1. Clone the project
  2. Set up an Android emulator and start it
  3. Run all instrumentation tests via ./gradlew connectedAndroidTest

Observed behavior

  • Four tests fails with the following error:
> Task :Umweltzone:connectedDebugAndroidTest
Starting 26 tests on API_18_4.3_Nexus_5_x86(AVD) - 4.3.1

de.avpptr.umweltzone.utils.ContentProviderTest > testGetAdministrativeZones_worksAtAll[API_18_4.3_Nexus_5_x86(AVD) - 4.3.1] FAILED 
  java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:198)

de.avpptr.umweltzone.utils.ContentProviderTest > testGetCircuits_usesCaches[API_18_4.3_Nexus_5_x86(AVD) - 4.3.1] FAILED 
  java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:198)

de.avpptr.umweltzone.utils.ContentProviderTest > testGetFaqs_worksAtAll[API_18_4.3_Nexus_5_x86(AVD) - 4.3.1] FAILED 
  java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:198)

de.avpptr.umweltzone.utils.ContentProviderTest > testGetCircuits_worksAtAll[API_18_4.3_Nexus_5_x86(AVD) - 4.3.1] FAILED 
  java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:198)

Stacktrace

java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:198)
  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:28)
  at com.fasterxml.jackson.databind.DeserializationContext.handlePrimaryContextualization(DeserializationContext.java:765)
  at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:535)
  at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:293)
  at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
  at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
  at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:558)
  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:188)
  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:28)
  at com.fasterxml.jackson.databind.DeserializationContext.handleSecondaryContextualization(DeserializationContext.java:796)
  at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:596)
  at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:4731)
  at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4592)
  at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3599)
  at de.avpptr.umweltzone.utils.ContentProvider.getContent(ContentProvider.java:120)
  at de.avpptr.umweltzone.utils.ContentProvider.getContent(ContentProvider.java:98)
  at de.avpptr.umweltzone.utils.ContentProvider.getAdministrativeZones(ContentProvider.java:74)
  at de.avpptr.umweltzone.utils.ContentProviderTest.testGetAdministrativeZones_worksAtAll(ContentProviderTest.java:133)

See: if ((!Objects.equals(unwrapSingle, _unwrapSingle)) at jackson-databind/CollectionDeserializer.java#L198

Expected behavior

  • No exception. Tests succeed.

Additional context

  • Tests succeed when com.fasterxml.jackson.core:jackson-databind:2.11.3 is used.

Related

@johnjohndoe johnjohndoe added the to-evaluate Issue that has been received but not yet evaluated label Apr 16, 2021
@cowtowncoder cowtowncoder added android Issues related to use on Android platform and removed to-evaluate Issue that has been received but not yet evaluated labels Apr 17, 2021
@cowtowncoder
Copy link
Member

I don't know what causes this, although suggestions from earlier issues suggest it might use of java.util.Objects; specifically Objects.equals().
This method is part of JDK 1.7 and is legal to use as per Jackson baseline; no change will be made to remove it.

So it might just be a limitation for use of Jackson with older versions of Android SDK at this point.

Jackson 2.13 will require Java 8 baseline.

@cowtowncoder
Copy link
Member

cowtowncoder commented Apr 17, 2021

Looks like java.util.Objects was added in Android API level 19 (Android 4.4):

https://developer.android.com/reference/kotlin/java/util/Objects

Jackson-databind did use this method in one place in 2.11, but much more extensively in 2.12.

I will add a note about this on 2.12 release notes:

https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.12

now. Also note that officially JDK 7 has been required since Jackson 2.8:

https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.8

@cowtowncoder cowtowncoder added the will-not-fix Closed as either non-issue or something not planned to be worked on label Apr 17, 2021
@johnjohndoe
Copy link
Contributor Author

Jackson-databind did use this method in one place in 2.11, but much more extensively in 2.12.

I found not too many places where Objects.equal is used. Did you consider using a compatibility wrapper inspired by ObjectsCompat from the androidx-core library?

@cowtowncoder
Copy link
Member

I was not aware of this being a compatibility concern so choice to use this method was for convenience, and not a conscious decision. But the way it turned out, I think, is that minimum baseline usable on Android was bumped from 18 to 19.
I don't think it worth trying to unroll this at this point in time.

What would be useful, however, would be some sort of test suite that could uncover such changes: something like jackson-android-compatibility-tests project, which could be run against Jackson versions. This to identify changes during release candidate phase.

@johnjohndoe
Copy link
Contributor Author

johnjohndoe commented Apr 18, 2021

... minimum baseline usable on Android was bumped from 18 to 19 ...

Do you mean: as an unintentional side effect?

What would be useful, however, would be some sort of test suite that could uncover such changes: something like jackson-android-compatibility-tests project, which could be run against Jackson versions. This to identify changes during release candidate phase.

I totally agree. That would be very valuable. That is how I discovered the issue myself. I use Travis CI to execute instrumentation tests (running Android emulator, android-18 in particular). That is possible with different CI systems as far as I know. I believe it would be sufficient to create a very basic Android project, add a few Android instrumentation tests and then set up the CI configuration. I have seen configurations which target different Android versions (build matrix). This would allow testing against Android SDK 18, 19, ...

@cowtowncoder
Copy link
Member

Correct, unintentional/unplanned change.
And yes, output on supported levels would be valuable so users could verify compatibility. This could also guide maintenance status of branches: just as an example it could make it more likely that certain branch could get patches longer than otherwise.

@johnjohndoe
Copy link
Contributor Author

Is my open source project, my open source CI configuration and the links enough information for you to set it up?

@cowtowncoder
Copy link
Member

That would be helpful for sure -- either me (if and when I have time), or perhaps someone else who would be interested in improving Android compatibility. I could ask on jackson-dev mailing list and twitter for collaborators. Just so that I won't become the main bottleneck.

@johnjohndoe
Copy link
Contributor Author

Sounds good to me. Feel free to ping me if I can be of help.

johnjohndoe added a commit to Umweltzone/Umweltzone that referenced this issue Nov 4, 2021
+ Jackson does no longer support these Android versions.
  See: FasterXML/jackson-databind#3123
+ Related: 6fad134.
johnjohndoe added a commit to Umweltzone/Umweltzone that referenced this issue Nov 5, 2021
+ Jackson does no longer support these Android versions.
  See: FasterXML/jackson-databind#3123
+ Related to Jackson: fc8a602
+ Related to BetterLinkMovementMethod: 6fad134.
johnjohndoe added a commit to Umweltzone/Umweltzone that referenced this issue Nov 5, 2021
+ Jackson does no longer support these Android versions.
  See: FasterXML/jackson-databind#3123
+ Related to Jackson: fc8a602
+ Related to BetterLinkMovementMethod: 6fad134.
johnjohndoe added a commit to Umweltzone/Umweltzone that referenced this issue Nov 5, 2021
+ Jackson does no longer support these Android versions.
  See: FasterXML/jackson-databind#3123
+ Related to Jackson: fc8a602
+ Related to BetterLinkMovementMethod: 6fad134.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Issues related to use on Android platform will-not-fix Closed as either non-issue or something not planned to be worked on
Projects
None yet
Development

No branches or pull requests

2 participants