diff options
author | shifujun <shifujun@foxmail.com> | 2023-12-08 14:48:28 +0800 |
---|---|---|
committer | shifujun <shifujun@foxmail.com> | 2023-12-08 17:18:27 +0800 |
commit | c04c375e813597eaeb305a641f58a89fe665ea54 (patch) | |
tree | 0ce0674728ec2a0b4a2c1d35d33dfa81a5cea3cc /src/main/javassist/compiler/MemberResolver.java | |
parent | 158294371e39b24f003f15933bd74f2b26bbf3aa (diff) | |
download | javassist-c04c375e813597eaeb305a641f58a89fe665ea54.tar.gz javassist-c04c375e813597eaeb305a641f58a89fe665ea54.zip |
Fix MemberResolver.lookupMethod bug when super class has more precise match
When onlyExact=false and super class have a more precise match,
it should not return with current class's maybe result.
New added testSuperCall reveals the problem.
Diffstat (limited to 'src/main/javassist/compiler/MemberResolver.java')
-rw-r--r-- | src/main/javassist/compiler/MemberResolver.java | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/main/javassist/compiler/MemberResolver.java b/src/main/javassist/compiler/MemberResolver.java index c01974df..dd271368 100644 --- a/src/main/javassist/compiler/MemberResolver.java +++ b/src/main/javassist/compiler/MemberResolver.java @@ -130,9 +130,7 @@ public class MemberResolver implements TokenId { if (onlyExact) maybe = null; - else - if (maybe != null) - return maybe; + //else maybe super class has more precise match int mod = clazz.getModifiers(); boolean isIntf = Modifier.isInterface(mod); @@ -143,8 +141,11 @@ public class MemberResolver implements TokenId { if (pclazz != null) { Method r = lookupMethod(pclazz, methodName, argTypes, argDims, argClassNames, onlyExact); - if (r != null) - return r; + if (r != null) { + if (maybe == null || maybe.notmatch > r.notmatch) { + maybe = r; + } + } } } } @@ -156,8 +157,11 @@ public class MemberResolver implements TokenId { Method r = lookupMethod(intf, methodName, argTypes, argDims, argClassNames, onlyExact); - if (r != null) - return r; + if (r != null) { + if (maybe == null || maybe.notmatch > r.notmatch) { + maybe = r; + } + } } if (isIntf) { @@ -166,8 +170,11 @@ public class MemberResolver implements TokenId { if (pclazz != null) { Method r = lookupMethod(pclazz, methodName, argTypes, argDims, argClassNames, onlyExact); - if (r != null) - return r; + if (r != null) { + if (maybe == null || maybe.notmatch > r.notmatch) { + maybe = r; + } + } } } } |