orfjackal/retrolambda — pull request #26 by Arneball (2014-08-11 15:17:59+00:00)
Title: package testpackage;

public interface MyInterface {
default String def() {
return "[" + toString() + ", " + "def]";
}

default String join(MyInterface other) {
return def() + other.def();
}
}

class C implements MyInterface{} compiles to:

public class testpackage.MyClass implements testpackage.MyInterface {
public testpackage.MyClass();
Code:
0: aload_0
1: invokespecial #16 // Method java/lang/Object."":()V
4: return

public java.lang.String join(testpackage.MyInterface);
Code:
0: aload_0
1: aload_1
2: invokestatic #46 // Method testpackage/MyInterfacehelper.join:(Ltestpackage/MyInterface;Ltestpackage/MyInterface;)Ljava/lang/String;
5: areturn

public java.lang.String def();
Code:
0: aload_0
1: invokestatic #49 // Method testpackage/MyInterfacehelper.def:(Ltestpackage/MyInterface;)Ljava/lang/String;
4: areturn
}

Where testpackage.MyInterfacehelper is compiled to
public class testpackage.MyInterfacehelper {
private testpackage.MyInterfacehelper();
Code:
0: aload_0
1: invokespecial #9 // Method java/lang/Object."":()V
4: return

public static java.lang.String def(testpackage.MyInterface);
Code:
0: new #13 // class java/lang/StringBuilder
3: dup
4: invokespecial #14 // Method java/lang/StringBuilder."":()V
7: ldc #16 // String [
9: invokevirtual #20 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
12: aload_0
13: invokevirtual #24 // Method java/lang/Object.toString:()Ljava/lang/String;
16: invokevirtual #20 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
19: ldc #26 // String ,
21: invokevirtual #20 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
24: ldc #28 // String def]
26: invokevirtual #20 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
29: invokevirtual #29 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
32: areturn

public static java.lang.String join(testpackage.MyInterface, testpackage.MyInterface);
Code:
0: new #13 // class java/lang/StringBuilder
3: dup
4: invokespecial #14 // Method java/lang/StringBuilder."":()V
7: aload_0
8: invokeinterface #35, 1 // InterfaceMethod testpackage/MyInterface.def:()Ljava/lang/String;
13: invokevirtual #20 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
16: aload_1
17: invokeinterface #35, 1 // InterfaceMethod testpackage/MyInterface.def:()Ljava/lang/String;
22: invokevirtual #20 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
25: invokevirtual #29 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
28: areturn
}

==============
interface StaticTest {
static T staticMethod(T t) {
return t;
}
}
compiles to
public class testpackage.StaticTesthelper {
private testpackage.StaticTesthelper();
Code:
0: aload_0
1: invokespecial #9 // Method java/lang/Object."":()V
4: return

public static T staticMethod$static(T);
Code:
0: aload_0
1: areturn
}

========

Brigde methods are generated properly in example:
public interface BridgeParent {
T get();
}
public interface StringBridges extends BridgeParent {
@Override
default String get() {
return "default method";
}

default String concrete() {
return "concrete";
}
}
public class testpackage.StringBridgeshelper
SourceFile: "testpackage/StringBridges.java"
minor version: 0
major version: 50
flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
#1 = Utf8 testpackage/StringBridgeshelper
#2 = Class #1 // testpackage/StringBridgeshelper
#3 = Utf8 java/lang/Object
#4 = Class #3 // java/lang/Object
#5 = Utf8 testpackage/StringBridges.java
#6 = Utf8
#7 = Utf8 ()V
#8 = NameAndType #6:#7 // "":()V
#9 = Methodref #4.#8 // java/lang/Object."":()V
#10 = Utf8 get
#11 = Utf8 (Ltestpackage/StringBridges;)Ljava/lang/String;
#12 = Utf8 default method
#13 = String #12 // default method
#14 = Utf8 concrete
#15 = String #14 // concrete
#16 = Utf8 (Ltestpackage/StringBridges;)Ljava/lang/Object;
#17 = Utf8 testpackage/StringBridges
#18 = Class #17 // testpackage/StringBridges
#19 = Utf8 ()Ljava/lang/String;
#20 = NameAndType #10:#19 // get:()Ljava/lang/String;
#21 = InterfaceMethodref #18.#20 // testpackage/StringBridges.get:()Ljava/lang/String;
#22 = Utf8 Code
#23 = Utf8 LineNumberTable
#24 = Utf8 SourceFile
{
private testpackage.StringBridgeshelper();
descriptor: ()V
flags: ACC_PRIVATE
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #9 // Method java/lang/Object."":()V
4: return

public static java.lang.String get(testpackage.StringBridges);
descriptor: (Ltestpackage/StringBridges;)Ljava/lang/String;
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=1, locals=1, args_size=1
0: ldc #13 // String default method
2: areturn
LineNumberTable:
line 9: 0

public static java.lang.String concrete(testpackage.StringBridges);
descriptor: (Ltestpackage/StringBridges;)Ljava/lang/String;
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=1, locals=1, args_size=1
0: ldc #15 // String concrete
2: areturn
LineNumberTable:
line 13: 0

public static java.lang.Object get(testpackage.StringBridges);
descriptor: (Ltestpackage/StringBridges;)Ljava/lang/Object;
flags: ACC_PUBLIC, ACC_STATIC, ACC_BRIDGE, ACC_SYNTHETIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokeinterface #21, 1 // InterfaceMethod testpackage/StringBridges.get:()Ljava/lang/String;
6: areturn
LineNumberTable:
line 6: 0
}