Skip to content

Commit

Permalink
Ensure compatibility with Android's limited Java SE subset
Browse files Browse the repository at this point in the history
Android utilizes a subset of the Java SE library, which excludes several packages and classes. This commit removes calls to methods unavailable on Android or wraps them in `try-catch` blocks with appropriate fallbacks. These changes ensure the Easy Random library functions on Android platforms.
  • Loading branch information
mjureczko committed Nov 23, 2024
1 parent c7fafb0 commit f8232f0
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,14 @@ public static void setProperty(final Object object, final Field field, final Obj
*/
public static void setFieldValue(final Object object, final Field field, final Object value)
throws IllegalAccessException {
boolean access = field.trySetAccessible();
field.set(object, value);
field.setAccessible(access);
try {
boolean access = field.trySetAccessible();
field.set(object, value);
field.setAccessible(access);
} catch (NoSuchMethodError e) {
field.setAccessible(true);
field.set(object, value);
}
}

/**
Expand Down

0 comments on commit f8232f0

Please sign in to comment.