From: chibash Date: Tue, 23 Feb 2016 16:57:05 +0000 (+0900) Subject: fixes JIRA JASSIST-250 X-Git-Tag: rel_3_21_0-java9-ea~14 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b110efa847be1d1f7c9d4932def4b49ea8a6dcaf;p=javassist.git fixes JIRA JASSIST-250 --- diff --git a/src/main/javassist/compiler/MemberResolver.java b/src/main/javassist/compiler/MemberResolver.java index ddbe1be4..a1073a76 100644 --- a/src/main/javassist/compiler/MemberResolver.java +++ b/src/main/javassist/compiler/MemberResolver.java @@ -104,7 +104,8 @@ public class MemberResolver implements TokenId { int n = list.size(); for (int i = 0; i < n; ++i) { MethodInfo minfo = (MethodInfo)list.get(i); - if (minfo.getName().equals(methodName)) { + if (minfo.getName().equals(methodName) + && (minfo.getAccessFlags() & AccessFlag.BRIDGE) == 0) { int res = compareSignature(minfo.getDescriptor(), argTypes, argDims, argClassNames); if (res != NO) { @@ -121,7 +122,8 @@ public class MemberResolver implements TokenId { if (onlyExact) maybe = null; else - onlyExact = maybe != null; + if (maybe != null) + return maybe; int mod = clazz.getModifiers(); boolean isIntf = Modifier.isInterface(mod); diff --git a/src/test/javassist/JvstTest5.java b/src/test/javassist/JvstTest5.java index 3c195faf..33740f7f 100644 --- a/src/test/javassist/JvstTest5.java +++ b/src/test/javassist/JvstTest5.java @@ -171,6 +171,18 @@ public class JvstTest5 extends JvstTestRoot { assertEquals(1, annotations.length); } + public void testJIRA250() throws Exception { + CtClass cc = sloader.makeClass("test5.JIRA250", sloader.get("test5.JIRA250Super")); + cc.addMethod(CtNewMethod.make( + " public test5.JIRA250Bar getBar() {" + + " return super.getBar();\n" + + " }\n", cc)); + cc.addMethod(CtNewMethod.make("public int run() { getBar(); return 1; }", cc)); + cc.writeFile(); + Object obj = make(cc.getName()); + assertEquals(1, invoke(obj, "run")); + } + public void testProceedToDefaultMethod() throws Exception { CtClass cc = ClassPool.getDefault().get("test5.ProceedDefault"); CtMethod mth = cc.getDeclaredMethod("bar"); diff --git a/src/test/test5/JIRA250Super.java b/src/test/test5/JIRA250Super.java new file mode 100644 index 00000000..9c328ee4 --- /dev/null +++ b/src/test/test5/JIRA250Super.java @@ -0,0 +1,17 @@ +package test5; + +interface JIRA250BarI { + int foo(); +} + +class JIRA250Bar implements JIRA250BarI { + public int foo() { return 1; } +} + +interface JIRA250SuperI { + JIRA250BarI getBar(); +} + +public class JIRA250Super extends JIRA250Super2 implements JIRA250SuperI { +} + diff --git a/src/test/test5/JIRA250Super2.java b/src/test/test5/JIRA250Super2.java new file mode 100644 index 00000000..919b0860 --- /dev/null +++ b/src/test/test5/JIRA250Super2.java @@ -0,0 +1,5 @@ +package test5; + +public class JIRA250Super2 { + public JIRA250Bar getBar() { return null; } +}