diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/javassist/bytecode/MethodParametersAttribute.java | 9 | ||||
-rw-r--r-- | src/main/javassist/compiler/MemberResolver.java | 25 |
2 files changed, 22 insertions, 12 deletions
diff --git a/src/main/javassist/bytecode/MethodParametersAttribute.java b/src/main/javassist/bytecode/MethodParametersAttribute.java index b9c252a9..f78f6c72 100644 --- a/src/main/javassist/bytecode/MethodParametersAttribute.java +++ b/src/main/javassist/bytecode/MethodParametersAttribute.java @@ -32,7 +32,8 @@ public class MethodParametersAttribute extends AttributeInfo { byte[] data = new byte[names.length * 4 + 1]; data[0] = (byte)names.length; for (int i = 0; i < names.length; i++) { - ByteArray.write16bit(cp.addUtf8Info(names[i]), data, i * 4 + 1); + String name = names[i]; + ByteArray.write16bit(name == null ? 0 : cp.addUtf8Info(name), data, i * 4 + 1); ByteArray.write16bit(flags[i], data, i * 4 + 3); } @@ -61,7 +62,8 @@ public class MethodParametersAttribute extends AttributeInfo { * @param i the position of the parameter. */ public String parameterName(int i) { - return getConstPool().getUtf8Info(name(i)); + int index = name(i); + return index == 0 ? null : getConstPool().getUtf8Info(index); } /** @@ -87,7 +89,8 @@ public class MethodParametersAttribute extends AttributeInfo { String[] names = new String[s]; int[] flags = new int[s]; for (int i = 0; i < s; i++) { - names[i] = cp.getUtf8Info(name(i)); + int index = name(i); + names[i] = index == 0 ? null : cp.getUtf8Info(index); flags[i] = accessFlags(i); } 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; + } + } } } } |