Browse Source

fixes JIRA JASSIST-248.

Javassist cannot compile super.m() if m is a default method
declared in an interface.
tags/rel_3_21_0-java9-ea
chibash 8 years ago
parent
commit
e44bf416bf

+ 1
- 1
Readme.html View File



<p>-version 3.21 <p>-version 3.21
<ul> <ul>
<li>JIRA JASSIST-244
<li>JIRA JASSIST-244, 248
</ul> </ul>
</p> </p>



BIN
javassist.jar View File


+ 1
- 1
src/main/javassist/compiler/MemberCodeGen.java View File

bytecode.addInvokestatic(declClass, mname, desc); bytecode.addInvokestatic(declClass, mname, desc);
} }
else if (isSpecial) // if (isSpecial && notStatic(acc)) else if (isSpecial) // if (isSpecial && notStatic(acc))
bytecode.addInvokespecial(declClass, mname, desc);
bytecode.addInvokespecial(targetClass, mname, desc);
else { else {
if (!Modifier.isPublic(declClass.getModifiers()) if (!Modifier.isPublic(declClass.getModifiers())
|| declClass.isInterface() != targetClass.isInterface()) || declClass.isInterface() != targetClass.isInterface())

+ 2
- 2
src/test/javassist/JvstTest5.java View File



public void testJIRA248() throws Exception { public void testJIRA248() throws Exception {
CtClass cc = sloader.get("test5.JIRA248"); 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); CtMethod ctMethod = CtMethod.make(methodBody, cc);
cc.addMethod(ctMethod); cc.addMethod(ctMethod);
cc.writeFile(); cc.writeFile();
Object obj = make(cc.getName()); Object obj = make(cc.getName());
assertEquals(71, invoke(obj, "run"));
assertEquals(271, invoke(obj, "run"));
} }
} }

+ 6
- 1
src/test/test5/JIRA248.java View File

default int foo() { return 1; } 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 class JIRA248 extends JIRA248Sup {
public int foo() { return 70; } public int foo() { return 70; }
public int bar() { return 3000; }
} }

Loading…
Cancel
Save