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:56:04 UTC
[groovy] branch danielsun/illgal-access-deny 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/illgal-access-deny
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/danielsun/illgal-access-deny by this push:
new 96d9d13 Fix illegal access to dynamic proxy
96d9d13 is described below
commit 96d9d1359db952d9b1b24f2310b6e2116f5db0c2
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());