You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rhino 1.7.14 is not available under Android SDK 21,java.lang.NoSuchMethodError: java.util.Map.putIfAbsent #1237
Caused by: java.lang.NoSuchMethodError: java.util.Map.putIfAbsent
at org.mozilla.javascript.JavaMembers.registerMethod(JavaMembers.java:389)
at org.mozilla.javascript.JavaMembers.discoverPublicMethods(JavaMembers.java:382)
at org.mozilla.javascript.JavaMembers.discoverAccessibleMethods(JavaMembers.java:355)
at org.mozilla.javascript.JavaMembers.discoverAccessibleMethods(JavaMembers.java:308)
at org.mozilla.javascript.JavaMembers.reflect(JavaMembers.java:425)
at org.mozilla.javascript.JavaMembers.<init>(JavaMembers.java:63)
at org.mozilla.javascript.JavaMembers.createJavaMembers(JavaMembers.java:833)
at org.mozilla.javascript.JavaMembers.lookupClass(JavaMembers.java:792)
at org.mozilla.javascript.NativeJavaObject.initMembers(NativeJavaObject.java:63)
at org.mozilla.javascript.NativeJavaObject.<init>(NativeJavaObject.java:53)
at org.mozilla.javascript.NativeJavaObject.<init>(NativeJavaObject.java:44)
at org.mozilla.javascript.WrapFactory.wrapAsJavaObject(WrapFactory.java:120)
at org.mozilla.javascript.WrapFactory.wrap(WrapFactory.java:74)
at org.mozilla.javascript.Context.javaToJS(Context.java:1753)
at org.mozilla.javascript.Context.javaToJS(Context.java:1712)
Replace the JavaMembers class back to 1.7.13 to solve the problem.
changed the title [-]Rhino 1.7.14 is not available under Android SDK 21,java.lang.NoSuchMethodError: java.util.Map.putIfAbsent[/-][+]Rhino 1.7.14 is not available under Android SDK 21,java.lang.NoSuchMethodError: java.util.Map.putIfAbsent[/+]on Jun 16, 2022
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.
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
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 java.util.
However, Java apis outside of java.util (eg #1149) are not supported. However, this issue may be solvable by using the desugaring.
Obviously, this will solve the problem with java.util.
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
However, Java apis outside of java.util (eg #1149) are not supported. However, this issue may be solvable by using the desugaring.
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
Activity
[-]Rhino 1.7.14 is not available under Android SDK 21,java.lang.NoSuchMethodError: java.util.Map.putIfAbsent[/-][+]Rhino 1.7.14 is not available under Android SDK 21,java.lang.NoSuchMethodError: java.util.Map.putIfAbsent[/+]p-bakker commentedon Jun 19, 2022
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
tonygermano commentedon Aug 2, 2022
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.
fix(#1237): polyfill android `Map.putIfAbsent`
p-bakker commentedon Nov 10, 2022
@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
naijun0403 commentedon Nov 10, 2022
Obviously, this will solve the problem with
java.util.However, Java apis outside of
java.util(eg #1149) are not supported. However, this issue may be solvable by using the desugaring.p-bakker commentedon Nov 10, 2022
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