This is an automated email from the ASF dual-hosted git repository. sunlan pushed a commit to branch danielsun/tweak-java16-support in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 3ab68e4a3d625cc3e90acc4d0808fce1707010da Author: Daniel Sun <[email protected]> AuthorDate: Tue Aug 24 17:12:56 2021 +0800 Trivial tweak: Avoid setting accessible when using Java 16+ --- src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java b/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java index e85883b..6b2d15b 100644 --- a/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java +++ b/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java @@ -48,6 +48,7 @@ import java.util.function.Function; @SuppressWarnings("rawtypes") public class ReflectionUtils { private static final VMPlugin VM_PLUGIN = VMPluginFactory.getPlugin(); + private static final int VM_PLUGIN_VERSION = VM_PLUGIN.getVersion(); /** The packages in the call stack that are only part of the Groovy MOP. */ private static final Set<String> IGNORED_PACKAGES; @@ -207,6 +208,7 @@ public class ReflectionUtils { } public static Optional<AccessibleObject> makeAccessibleInPrivilegedAction(final AccessibleObject ao) { + if (VM_PLUGIN_VERSION >= 16) return Optional.empty(); // illegal reflective access is forbidden since Java 16 return AccessController.doPrivileged((PrivilegedAction<Optional<AccessibleObject>>) () -> makeAccessible(ao)); }
