Skip to content

Commit

Permalink
fix: The trySetAccessible method does not exist on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
naijun0403 committed Sep 20, 2024
1 parent e217cee commit 39c4804
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rhino/src/main/java/org/mozilla/javascript/JavaMembers.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ private void discoverAccessibleMethods(
if (isPublic(mods) || isProtected(mods) || includePrivate) {
MethodSignature sig = new MethodSignature(method);
if (!map.containsKey(sig)) {
if (includePrivate) method.trySetAccessible();
if (includePrivate && !method.isAccessible())
method.setAccessible(true);
map.put(sig, method);
}
}
Expand Down Expand Up @@ -667,7 +668,7 @@ private Field[] getAccessibleFields(boolean includeProtected, boolean includePri
for (Field field : declared) {
int mod = field.getModifiers();
if (includePrivate || isPublic(mod) || isProtected(mod)) {
field.trySetAccessible();
if (!field.isAccessible()) field.setAccessible(true);
fieldsList.add(field);
}
}
Expand Down

0 comments on commit 39c4804

Please sign in to comment.