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/06/13 10:57:08 UTC

[groovy] branch danielsun/tweak-build updated: Fix illegal access to dynamic proxy

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

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


The following commit(s) were added to refs/heads/danielsun/tweak-build by this push:
     new 0bc9932  Fix illegal access to dynamic proxy
0bc9932 is described below

commit 0bc993211faa0cd597ed1f8f585eb663250810d7
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Jun 13 18:55:34 2021 +0800

    Fix illegal access to dynamic proxy
---
 src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
index 1600070..bf476e4 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
@@ -42,6 +42,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
 import java.math.BigInteger;
 import java.net.URI;
 import java.util.ArrayList;
@@ -179,6 +180,12 @@ public class Java9 extends Java8 {
 
     public static MethodHandles.Lookup of(final Class<?> declaringClass) {
         try {
+            // All proxy classes are not open for reflective access in Java SE 16
+            // See also https://www.oracle.com/java/technologies/javase/16-relnotes.html
+            if (Proxy.isProxyClass(declaringClass)) {
+                return MethodHandles.lookup().in(declaringClass);
+            }
+
             final Method privateLookup = getPrivateLookup();
             if (privateLookup != null) {
                 return (MethodHandles.Lookup) privateLookup.invoke(null, declaringClass, MethodHandles.lookup());