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

Version 2.14.0 uses Method.getParameterCount() which is not supported on Android before API 26 #3658

Closed
jonnycaley opened this issue Nov 11, 2022 · 8 comments
Labels
android Issues related to use on Android platform

Comments

@jonnycaley
Copy link

jonnycaley commented Nov 11, 2022

Describe the bug

This previous issue was re-introduced with the usage of getParameterCount in src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java as seen in the release changes.

Version information
Which Jackson version(s) was this for?

2.14.0

To Reproduce

Run the following code on a device running Android 24:

ObjectMapper().writeValueAsString(mapOf<String, Any>())

Expected behavior
Exception java.lang.NoSuchMethodError: No virtual method getParameterCount()I in class Ljava/lang/reflect/Method; or its super classes (declaration of 'java.lang.reflect.Method' appears in /system/framework/core-oj.jar) is not thrown

Additional context
Add any other context about the problem here.

Crashes on Android device running API 24

@jonnycaley jonnycaley added the to-evaluate Issue that has been received but not yet evaluated label Nov 11, 2022
@jonnycaley jonnycaley changed the title java.lang.NoSuchMethodError: No virtual method getParameterCount()I in class Ljava/lang/reflect/Method; or its super classes (declaration of 'java.lang.reflect.Method' appears in /system/framework/core-oj.jar) Version 2.14.0 uses Method.getParameterCount() which is not supported on Android before API 26 Nov 11, 2022
@cowtowncoder
Copy link
Member

I wish we had CI tests for Android compatibility testing. Also wish I had remembered that this had already been an issue quite recently (see #3412).

But at this point I am tempted to say that the baseline Android SDK Jackson works with is 26; and for earlier SDKs one needs to use 2.13 or earlier.

@cowtowncoder
Copy link
Member

cowtowncoder commented Nov 13, 2022

I am now adding Android SDK compatibility verification (via #3659) and it looks like 2.13 is compatible with Android SDK 24, except for use of Class.getTypeName() (26-only) -- this is issue #3661 that I fixed and will be in 2.13.5.

Beyond that I think that verified minimum working baseline will be such that:

  • Jackson 2.13 should work with ASDK 24 and above (may work with earlier but as per AnimalSniffer this is the safe baseline)
  • Jackson 2.14 should work with ASDK 26 and above

@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 Nov 13, 2022
@cowtowncoder
Copy link
Member

Will mark this as closed given that it is basically "works as planned" in that the idea was (but that I had forgotten) to start using specific method in 2.14.

We now finally have actual checking for Android SDK compatibility for databind so that we shouldn't accidentally break compatibility going forward. But we also need to add notes on what the actual compatibility is, on README -- I will file another issue. Similarly for jackson-core.

@jonnycaley
Copy link
Author

Thanks for the updates 🚀

@cowtowncoder
Copy link
Member

You are welcome @jonnycaley !

@adhirajsinghchauhan
Copy link

adhirajsinghchauhan commented Dec 29, 2022

Would it be possible to add some kind of a build-time warning/error? Normally one doesn't expect a minor release to intentionally (also permanently it seems: #3702 (comment)) break backwards compatibility, if you're going by semver:

MINOR version when you add functionality in a backwards compatible manner

Sometimes devs are lazy and don't boot up an old device to check if things still work after a minor dep update, so seeing a message at build-time would be preferable to finding out after releasing to prod.

adhirajsinghchauhan added a commit to oxygen-updater/oxygen-updater that referenced this issue Dec 29, 2022
Koin 3.3.1 -> 3.3.2

Downgraded Jackson Kotlin Module from 2.14.1 -> 2.13.4 because of FasterXML/jackson-databind#3658
@yawkat
Copy link
Member

yawkat commented Jan 2, 2023

I don't think it's possible

@cowtowncoder
Copy link
Member

Wrt SemVer: although in perfect world major versions would be used to indicate compatibility changes, in practice this is not a workable for Jackson, given that a new major version behaves more like a fork (new package names, new Maven coordinates). So incremental changes to baseline requirements (minimum JDK has changes from Java 6 to Java 8 during Jackson 2.x, as another example) need to be made in minor versions.

I am not sure how build time warning could work; especially since it specifically affects a subset of developers (Android devleopers).
I am open to suggestions, as usual, just not sure how to go about this.

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
Projects
None yet
Development

No branches or pull requests

4 participants