diff --git a/easy-random-core/src/main/java/org/jeasy/random/util/ReflectionUtils.java b/easy-random-core/src/main/java/org/jeasy/random/util/ReflectionUtils.java index 1b42926d..94c3387e 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/util/ReflectionUtils.java +++ b/easy-random-core/src/main/java/org/jeasy/random/util/ReflectionUtils.java @@ -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); + } } /**