groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 04/08: Minor refactoring: pull the implementation up to super class
Date Sat, 02 Nov 2019 21:47:01 GMT
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 076433f9d4fd1141ddf6be0919e0e531ba86456d
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Sun Nov 3 01:25:49 2019 +0800

    Minor refactoring: pull the implementation up to super class
    
    (cherry picked from commit bd5b786a57bef89b94cab9569ea234ee2099b902)
---
 src/main/java/org/codehaus/groovy/vmplugin/v5/Java5.java |  2 +-
 src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v5/Java5.java b/src/main/java/org/codehaus/groovy/vmplugin/v5/Java5.java
index ff52fb8..08bee6e 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v5/Java5.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v5/Java5.java
@@ -593,7 +593,7 @@ public class Java5 implements VMPlugin {
 
     @Override
     public MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?>[]
params) {
-        return metaMethod;
+        return transformMetaMethod(metaClass, metaMethod, params, null);
     }
 
     private static final Permission ACCESS_PERMISSION = new ReflectPermission("suppressAccessChecks");
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 ab6d335..b067add 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
@@ -50,6 +50,7 @@ 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;
@@ -168,11 +169,6 @@ public class Java9 extends Java8 {
     }
 
     @Override
-    public MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?>[]
params) {
-        return transformMetaMethod(metaClass, metaMethod, params, ReflectionUtils.getCallingClass());
-    }
-
-    @Override
     public MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?>[]
params, Class<?> caller) {
         if (!(metaMethod instanceof CachedMethod)) {
             return metaMethod;
@@ -190,6 +186,10 @@ public class Java9 extends Java8 {
 
         int methodModifiers = cachedMethod.getModifiers();
 
+        if (null == caller) {
+            caller = Objects.requireNonNull(ReflectionUtils.getCallingClass(), "Failed to
get caller class");
+        }
+
         // if caller can access the method,
         // no need to transform the meta method
         if (checkAccessible(caller, declaringClass, methodModifiers, false)) {


Mime
View raw message