You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/08/24 09:13:19 UTC

[groovy] branch danielsun/tweak-java16-support created (now 3ab68e4)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch danielsun/tweak-java16-support
in repository https://gitbox.apache.org/repos/asf/groovy.git.


      at 3ab68e4  Trivial tweak: Avoid setting accessible when using Java 16+

This branch includes the following new commits:

     new 3ab68e4  Trivial tweak: Avoid setting accessible when using Java 16+

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[groovy] 01/01: Trivial tweak: Avoid setting accessible when using Java 16+

Posted by su...@apache.org.
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 <su...@apache.org>
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));
     }