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 2019/11/02 21:47:05 UTC

[groovy] 08/08: Fix the caller class

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

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 4c17ab76da202a57cd5fa56305df160e69edd1ed
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Nov 3 05:18:34 2019 +0800

    Fix the caller class
    
    (cherry picked from commit 319c3e73019fb83158665346b1c5bd1134ec7d6b)
---
 src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

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 b067add..797eae0 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
@@ -50,7 +50,6 @@ import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
@@ -162,7 +161,6 @@ public class Java9 extends Java8 {
         return checkAccessible(callerClass, declaringClass, modifiers, true);
     }
 
-
     @Override
     public boolean trySetAccessible(AccessibleObject ao) {
         return ao.trySetAccessible();
@@ -186,9 +184,7 @@ public class Java9 extends Java8 {
 
         int methodModifiers = cachedMethod.getModifiers();
 
-        if (null == caller) {
-            caller = Objects.requireNonNull(ReflectionUtils.getCallingClass(), "Failed to get caller class");
-        }
+        caller = ReflectionUtils.class; // "set accessible" are done via `org.codehaus.groovy.reflection.ReflectionUtils` as shown in warnings
 
         // if caller can access the method,
         // no need to transform the meta method