Avoid redundant looking up to find valid methods
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 @@
}
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();