[groovy] branch GROOVY_3_0_X updated: Avoid redundant looking up to find valid methods

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[groovy] branch GROOVY_3_0_X updated: Avoid redundant looking up to find valid methods

Daniel.Sun
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


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
     new 367584a  Avoid redundant looking up to find valid methods
367584a is described below

commit 367584a475ca7c411fc87d7d12c89e545dec2baf
Author: Daniel Sun <[hidden email]>
AuthorDate: Tue Dec 3 10:33:52 2019 +0800

    Avoid redundant looking up to find valid methods
   
    (cherry picked from commit 8b33c7b0314496e1a7decd295a6c468e4ef6a657)
---
 src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 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 bbf56de..9dcadb7 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
@@ -229,14 +229,12 @@ public class Java9 extends Java8 {
             }
 
             return metaMethod;
-        }
-
-        // if caller can not access the method,
-        // try to find the corresponding method in its derived class
-        // GROOVY-9081 Sub-class derives the protected members from public class, "Invoke the members on the sub class instances"
-        // e.g. StringBuilder sb = new StringBuilder(); sb.setLength(0);
-        // `setLength` is the method of `AbstractStringBuilder`, which is `package-private`
-        if (declaringClass.isAssignableFrom(theClass)) {
+        } else if (declaringClass.isAssignableFrom(theClass)) {
+            // if caller can not access the method,
+            // try to find the corresponding method in its derived class
+            // GROOVY-9081 Sub-class derives the protected members from public class, "Invoke the members on the sub class instances"
+            // e.g. StringBuilder sb = new StringBuilder(); sb.setLength(0);
+            // `setLength` is the method of `AbstractStringBuilder`, which is `package-private`
             Optional<CachedMethod> optionalMetaMethod = getAccessibleMetaMethod(metaMethod, params, caller, theClass);
             if (optionalMetaMethod.isPresent()) {
                 return optionalMetaMethod.get();

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun