From e44bf416bf4f7d705deef9f9243197d4fff9f2d0 Mon Sep 17 00:00:00 2001 From: chibash Date: Fri, 25 Sep 2015 15:08:57 +0900 Subject: fixes JIRA JASSIST-248. Javassist cannot compile super.m() if m is a default method declared in an interface. --- Readme.html | 2 +- javassist.jar | Bin 724840 -> 725035 bytes src/main/javassist/compiler/MemberCodeGen.java | 2 +- src/test/javassist/JvstTest5.java | 4 ++-- src/test/test5/JIRA248.java | 7 ++++++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Readme.html b/Readme.html index c646c9a6..c3046502 100644 --- a/Readme.html +++ b/Readme.html @@ -283,7 +283,7 @@ see javassist.Dump.

-version 3.21

diff --git a/javassist.jar b/javassist.jar index 7cae24bb..971c83ed 100644 Binary files a/javassist.jar and b/javassist.jar differ diff --git a/src/main/javassist/compiler/MemberCodeGen.java b/src/main/javassist/compiler/MemberCodeGen.java index 67031992..b1f932ca 100644 --- a/src/main/javassist/compiler/MemberCodeGen.java +++ b/src/main/javassist/compiler/MemberCodeGen.java @@ -642,7 +642,7 @@ public class MemberCodeGen extends CodeGen { bytecode.addInvokestatic(declClass, mname, desc); } else if (isSpecial) // if (isSpecial && notStatic(acc)) - bytecode.addInvokespecial(declClass, mname, desc); + bytecode.addInvokespecial(targetClass, mname, desc); else { if (!Modifier.isPublic(declClass.getModifiers()) || declClass.isInterface() != targetClass.isInterface()) diff --git a/src/test/javassist/JvstTest5.java b/src/test/javassist/JvstTest5.java index 249f4fad..1767436e 100644 --- a/src/test/javassist/JvstTest5.java +++ b/src/test/javassist/JvstTest5.java @@ -128,11 +128,11 @@ public class JvstTest5 extends JvstTestRoot { public void testJIRA248() throws Exception { CtClass cc = sloader.get("test5.JIRA248"); - String methodBody = "public int run() { return foo() + super.foo(); }"; + String methodBody = "public int run() { return foo() + super.foo() + super.bar(); }"; CtMethod ctMethod = CtMethod.make(methodBody, cc); cc.addMethod(ctMethod); cc.writeFile(); Object obj = make(cc.getName()); - assertEquals(71, invoke(obj, "run")); + assertEquals(271, invoke(obj, "run")); } } diff --git a/src/test/test5/JIRA248.java b/src/test/test5/JIRA248.java index 0a0abcbe..5ea8472f 100644 --- a/src/test/test5/JIRA248.java +++ b/src/test/test5/JIRA248.java @@ -4,9 +4,14 @@ interface JIRA248Intf { default int foo() { return 1; } } -class JIRA248Sup implements JIRA248Intf { +class JIRA248Sup2 { + public int bar() { return 200; } +} + +class JIRA248Sup extends JIRA248Sup2 implements JIRA248Intf { } public class JIRA248 extends JIRA248Sup { public int foo() { return 70; } + public int bar() { return 3000; } } -- cgit v1.2.3