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:34:18 UTC
[groovy] branch master 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 master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 8b33c7b Avoid redundant looking up to find valid methods
8b33c7b is described below
commit 8b33c7b0314496e1a7decd295a6c468e4ef6a657
Author: Daniel Sun <su...@apache.org>
AuthorDate: Tue Dec 3 10:33:52 2019 +0800
Avoid redundant looking up to find valid methods
---
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();