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/12/03 02:36:44 UTC
[groovy] branch GROOVY_3_0_X updated: Avoid redundant looking up to
find valid methods
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 <su...@apache.org>
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();