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 2021/06/26 06:32:31 UTC
[groovy] branch master updated: Access more methods if "spy" found
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 0c44604 Access more methods if "spy" found
0c44604 is described below
commit 0c446044b35a17ad897b173ce894674cab719d9a
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jun 26 13:16:34 2021 +0800
Access more methods if "spy" found
---
src/main/java/groovy/lang/MetaClassImpl.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/main/java/groovy/lang/MetaClassImpl.java b/src/main/java/groovy/lang/MetaClassImpl.java
index 7624e41..029deac 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -1207,7 +1207,8 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
throw mme;
}
- if (null == lookup) {
+ final boolean spyFound = null != lookup;
+ if (!spyFound) {
try {
lookup = MethodHandles.lookup().in(receiverClass);
} catch (IllegalArgumentException e) {
@@ -1217,6 +1218,8 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
MethodHandles.Lookup tmpLookup = lookup;
MethodHandle thisMethodHandle = findMethod(receiverClass, methodName, castArgumentsToClassArray(originalArguments), thisMethod -> {
try {
+ if (spyFound) return tmpLookup.unreflectSpecial(thisMethod, receiverClass);
+
return tmpLookup.unreflect(thisMethod);
} catch (IllegalAccessException e) {
return null;