groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 03/03: Minor refactoring: Remove redundant parameter
Date Fri, 29 Nov 2019 05:42:12 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 230776593a3c1cdf92ae0d4df58e0b46efae7502
Author: Daniel.Sun <realbluesun@hotmail.com>
AuthorDate: Fri Nov 29 12:39:47 2019 +0800

    Minor refactoring: Remove redundant parameter
    
    (cherry picked from commit c8b32dab918cfe0abee29b6249ec03f6fa07449b)
---
 src/main/java/groovy/lang/MetaClassImpl.java            |  6 +++---
 .../org/codehaus/groovy/reflection/CachedMethod.java    | 17 -----------------
 .../groovy/runtime/callsite/PogoMetaMethodSite.java     |  2 +-
 .../groovy/runtime/callsite/PojoMetaMethodSite.java     |  2 +-
 .../java/org/codehaus/groovy/vmplugin/VMPlugin.java     |  6 ++----
 .../java/org/codehaus/groovy/vmplugin/v5/Java5.java     |  6 +++---
 .../java/org/codehaus/groovy/vmplugin/v7/Selector.java  |  2 +-
 .../java/org/codehaus/groovy/vmplugin/v9/Java9.java     |  3 ++-
 8 files changed, 13 insertions(+), 31 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java b/src/main/java/groovy/lang/MetaClassImpl.java
index cde9109..e82ba38 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -1257,7 +1257,7 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
         }
 
         if (method != null) {
-            MetaMethod transformedMetaMethod = VMPluginFactory.getPlugin().transformMetaMethod(this,
method, MetaClassHelper.convertToTypeArray(arguments));
+            MetaMethod transformedMetaMethod = VMPluginFactory.getPlugin().transformMetaMethod(this,
method);
             return transformedMetaMethod.doMethodInvoke(object, arguments);
         } else {
             return invokePropertyOrMissing(object, methodName, originalArguments, fromInsideClass,
isCallToSuper);
@@ -1913,7 +1913,7 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
             //----------------------------------------------------------------------
             // executing the getter method
             //----------------------------------------------------------------------
-            MetaMethod transformedMetaMethod = VMPluginFactory.getPlugin().transformMetaMethod(this,
method, MetaClassHelper.convertToTypeArray(arguments));
+            MetaMethod transformedMetaMethod = VMPluginFactory.getPlugin().transformMetaMethod(this,
method);
             return transformedMetaMethod.doMethodInvoke(object, arguments);
         }
 
@@ -2812,7 +2812,7 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
                 arguments[1] = newValue;
             }
 
-            MetaMethod transformedMetaMethod = VMPluginFactory.getPlugin().transformMetaMethod(this,
method, MetaClassHelper.convertToTypeArray(arguments));
+            MetaMethod transformedMetaMethod = VMPluginFactory.getPlugin().transformMetaMethod(this,
method);
             transformedMetaMethod.doMethodInvoke(object, arguments);
             return;
         }
diff --git a/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java b/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java
index fb342bf..fec89fc 100644
--- a/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java
+++ b/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java
@@ -95,23 +95,6 @@ public class CachedMethod extends MetaMethod implements Comparable {
     }
 
     public final Object invoke(Object object, Object[] arguments) {
-        /*
-        CachedMethod transformedCachedMethod =
-                (CachedMethod) CallSiteHelper.transformMetaMethod(
-                        InvokerHelper.getMetaClass(object.getClass()),
-                        this,
-                        this.getPT(),
-                        CachedMethod.class);
-
-        Method cachedMethod = transformedCachedMethod.cachedMethod;
-
-        if (transformedCachedMethod == this) {
-            makeAccessibleIfNecessary();
-        } else {
-            ReflectionUtils.trySetAccessible(cachedMethod);
-        }
-        */
-
         makeAccessibleIfNecessary();
 
         try {
diff --git a/src/main/java/org/codehaus/groovy/runtime/callsite/PogoMetaMethodSite.java b/src/main/java/org/codehaus/groovy/runtime/callsite/PogoMetaMethodSite.java
index 89a563e..a992f3c 100644
--- a/src/main/java/org/codehaus/groovy/runtime/callsite/PogoMetaMethodSite.java
+++ b/src/main/java/org/codehaus/groovy/runtime/callsite/PogoMetaMethodSite.java
@@ -160,7 +160,7 @@ public class PogoMetaMethodSite extends PlainObjectMetaMethodSite {
         final Method reflect;
 
         public PogoCachedMethodSite(CallSite site, MetaClassImpl metaClass, CachedMethod
metaMethod, Class[] params) {
-            super(site, metaClass, VM_PLUGIN.transformMetaMethod(metaClass, metaMethod, params),
params);
+            super(site, metaClass, VM_PLUGIN.transformMetaMethod(metaClass, metaMethod),
params);
             reflect = ((CachedMethod) super.metaMethod).setAccessible();
         }
 
diff --git a/src/main/java/org/codehaus/groovy/runtime/callsite/PojoMetaMethodSite.java b/src/main/java/org/codehaus/groovy/runtime/callsite/PojoMetaMethodSite.java
index ff77eea..7b54125 100644
--- a/src/main/java/org/codehaus/groovy/runtime/callsite/PojoMetaMethodSite.java
+++ b/src/main/java/org/codehaus/groovy/runtime/callsite/PojoMetaMethodSite.java
@@ -181,7 +181,7 @@ public class PojoMetaMethodSite extends PlainObjectMetaMethodSite {
         final Method reflect;
 
         public PojoCachedMethodSite(CallSite site, MetaClassImpl metaClass, MetaMethod metaMethod,
Class[] params) {
-            super(site, metaClass, VM_PLUGIN.transformMetaMethod(metaClass, metaMethod, params),
params);
+            super(site, metaClass, VM_PLUGIN.transformMetaMethod(metaClass, metaMethod),
params);
             reflect = ((CachedMethod) super.metaMethod).setAccessible();
         }
 
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java b/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java
index 58caf26..40ba4fb 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java
@@ -98,19 +98,17 @@ public interface VMPlugin {
      *
      * @param metaClass meta class
      * @param metaMethod the original meta method
-     * @param params parameter types
      * @param caller caller class, whose method sets accessible for methods
      * @return the transformed meta method
      */
-    MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?>[]
params, Class<?> caller);
+    MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?>
caller);
 
     /**
      * transform meta method.
      *
      * @param metaClass meta class
      * @param metaMethod the original meta method
-     * @param params parameter types
      * @return the transformed meta method
      */
-    MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?>[]
params);
+    MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod);
 }
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 08bee6e..0f3b668 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v5/Java5.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v5/Java5.java
@@ -587,13 +587,13 @@ public class Java5 implements VMPlugin {
     }
 
     @Override
-    public MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?>[]
params, Class<?> caller) {
+    public MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?>
caller) {
         return metaMethod;
     }
 
     @Override
-    public MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?>[]
params) {
-        return transformMetaMethod(metaClass, metaMethod, params, null);
+    public MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod) {
+        return transformMetaMethod(metaClass, metaMethod, null);
     }
 
     private static final Permission ACCESS_PERMISSION = new ReflectPermission("suppressAccessChecks");
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
index 7872c67..1f1174f 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
@@ -634,7 +634,7 @@ public abstract class Selector {
             if (metaMethod instanceof CachedMethod) {
                 if (LOG_ENABLED) LOG.info("meta method is CachedMethod instance");
                 CachedMethod cm = (CachedMethod) metaMethod;
-                cm = (CachedMethod) VMPluginFactory.getPlugin().transformMetaMethod(getMetaClass(),
cm, cm.getPT());
+                cm = (CachedMethod) VMPluginFactory.getPlugin().transformMetaMethod(getMetaClass(),
cm);
                 isVargs = cm.isVargsMethod();
                 try {
                     Method m = cm.getCachedMethod();
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 d482e89..5243df3 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
@@ -164,7 +164,7 @@ public class Java9 extends Java8 {
     }
 
     @Override
-    public MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?>[]
params, Class<?> caller) {
+    public MetaMethod transformMetaMethod(MetaClass metaClass, MetaMethod metaMethod, Class<?>
caller) {
         if (!(metaMethod instanceof CachedMethod)) {
             return metaMethod;
         }
@@ -190,6 +190,7 @@ public class Java9 extends Java8 {
             return metaMethod;
         }
 
+        Class<?>[] params = cachedMethod.getPT();
         Class<?> theClass = metaClass.getTheClass();
         if (declaringClass == theClass) {
             if (BigInteger.class == theClass) {


Mime
View raw message