]> source.dussan.org Git - javassist.git/commitdiff
fixes JIRA JASSIST-250
authorchibash <chiba@javassist.org>
Tue, 23 Feb 2016 16:57:05 +0000 (01:57 +0900)
committerchibash <chiba@javassist.org>
Tue, 23 Feb 2016 16:57:05 +0000 (01:57 +0900)
src/main/javassist/compiler/MemberResolver.java
src/test/javassist/JvstTest5.java
src/test/test5/JIRA250Super.java [new file with mode: 0644]
src/test/test5/JIRA250Super2.java [new file with mode: 0644]

index ddbe1be406dc0076bc83e418b0a90a1c5b5586ca..a1073a76e99ca368f4e830a049d1d93b62c04173 100644 (file)
@@ -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);
index 3c195fafe9313be0bc7ae5fdaa9cb899a3f199c6..33740f7f059b5d29f614b3aaf8d5bd037f322a23 100644 (file)
@@ -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 (file)
index 0000000..9c328ee
--- /dev/null
@@ -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 (file)
index 0000000..919b086
--- /dev/null
@@ -0,0 +1,5 @@
+package test5;
+
+public class JIRA250Super2 {
+    public JIRA250Bar getBar() { return null; }
+}