-
Notifications
You must be signed in to change notification settings - Fork 866
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
Rhino 1.7.14 is not available under Android SDK 21,java.lang.NoSuchMethodError: java.util.Map.putIfAbsent #1237
Comments
Map.putIfAbsent only got added in API version 24, see https://developer.android.com/reference/java/util/Map#putIfAbsent(K,%20V), whereas in Java it got added in 1.8 So we'll need to see whether we can prevent the reported error from occurring, but this also ties into the larger challenge of running the entire Rhino testsuite against Android (after determining which Android SDK versions we can/should support), as to prevent such breakage from occurring in the first place. Any help getting this going from Rhino users on Android would be more than welcome |
API version 24 corresponds to Android 7. Currently only versions 10+ are still maintained. Version 6, which is the newest version without putIfAbsent, has not had a security update since August 2018. |
Remove usage of putIfAbsent() in the Hashmap class. This method does not exist on many old Android releases and there's no real downside to removing it. Fixes #1237
@ylk2534246654 @naijun0403 question about this issue with Map.putIfAbsent on Android: from what I understand, when Java code is compiled to run on Android, the D8 compiler would take care of desugaring Map.putIfAbsent if properly configured, see https://developer.android.com/studio/write/java8-support#library-desugaring and https://developer.android.com/studio/write/java8-support-table Asking because I'm wondering if this issue was indeed something that needed fixing on the Rhino side and in the future we ought to remain careful not to introduce similar issues again or whether this is something that could've been handled with proper build config on the Android side |
Obviously, this will solve the problem with However, Java apis outside of |
K, great, tnx for the information. I'll make a note to add to the Android documentation to make sure to configure the build process on Android as such that it'll desugar unavailable API's when targeting old Android versions, so within Rhino we don't have to keep Android compatibility in the back of our mind in that regards
Yup, that is understood. We're open to suggestions or better yet help in setting up something on our CI to surface such incompatibilities, see #1152 and some of the comments in #1149 |
Stack trace:
Replace the JavaMembers class back to 1.7.13 to solve the problem.
The text was updated successfully, but these errors were encountered: