-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for the missing lambda body (#328)
- Loading branch information
Showing
3 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package pkg; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public class TestMissingLambdaBody { | ||
public void init() { | ||
this.visit(var1 -> {// 24 31 | ||
});// 69 | ||
}// 32 | ||
|
||
public void visit(Consumer var1) { | ||
var1.accept("Foo".hashCode());// 38 39 40 41 42 | ||
var1.accept("Bar".length());// 43 44 45 46 47 | ||
}// 48 | ||
|
||
public Number accept(Number var1) { | ||
System.out.println(var1);// 54 55 56 | ||
return var1;// 57 58 | ||
} | ||
} | ||
|
||
class 'pkg/TestMissingLambdaBody' { | ||
method 'init ()V' { | ||
0 6 | ||
7 6 | ||
8 6 | ||
9 6 | ||
a 8 | ||
} | ||
|
||
method 'lambda$init$0 (Ljava/lang/Integer;)V' { | ||
9 7 | ||
} | ||
|
||
method 'visit (Ljava/util/function/Consumer;)V' { | ||
0 11 | ||
1 11 | ||
2 11 | ||
3 11 | ||
4 11 | ||
5 11 | ||
6 11 | ||
7 11 | ||
8 11 | ||
9 11 | ||
a 11 | ||
b 11 | ||
c 11 | ||
d 11 | ||
e 12 | ||
f 12 | ||
10 12 | ||
11 12 | ||
12 12 | ||
13 12 | ||
14 12 | ||
15 12 | ||
16 12 | ||
17 12 | ||
18 12 | ||
19 12 | ||
1a 12 | ||
1b 12 | ||
1c 13 | ||
} | ||
|
||
method 'accept (Ljava/lang/Number;)Ljava/lang/Number;' { | ||
0 16 | ||
1 16 | ||
2 16 | ||
3 16 | ||
4 16 | ||
5 16 | ||
6 16 | ||
7 17 | ||
8 17 | ||
} | ||
} | ||
|
||
Lines mapping: | ||
24 <-> 7 | ||
31 <-> 7 | ||
32 <-> 9 | ||
38 <-> 12 | ||
39 <-> 12 | ||
40 <-> 12 | ||
41 <-> 12 | ||
42 <-> 12 | ||
43 <-> 13 | ||
44 <-> 13 | ||
45 <-> 13 | ||
46 <-> 13 | ||
47 <-> 13 | ||
48 <-> 14 | ||
54 <-> 17 | ||
55 <-> 17 | ||
56 <-> 17 | ||
57 <-> 18 | ||
58 <-> 18 | ||
69 <-> 8 | ||
Not mapped: | ||
25 | ||
26 | ||
64 | ||
65 | ||
66 | ||
67 | ||
68 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* This code can be assembled with <a href="https://wiki.openjdk.java.net/display/CodeTools/asmtools">asmtools</a> | ||
* using <code>asmtools jasm -g *.jasm</code> command line. | ||
*/ | ||
package pkg; | ||
|
||
super public class TestMissingLambdaBody | ||
version 52:0 | ||
{ | ||
// weird fix | ||
const #1 = Method TestMissingLambdaBody.lambda$init$0:"(Ljava/lang/Integer;)V"; | ||
|
||
public Method "<init>":"()V" | ||
stack 1 locals 1 | ||
{ | ||
aload_0; | ||
invokespecial Method java/lang/Object."<init>":"()V"; | ||
return; | ||
|
||
} | ||
public Method init:"()V" | ||
stack 2 locals 1 | ||
{ | ||
aload_0; | ||
aload_0; | ||
invokedynamic InvokeDynamic REF_invokeStatic:Method java/lang/invoke/LambdaMetafactory.metafactory:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;":accept:"(Lpkg/TestMissingLambdaBody;)Ljava/util/function/Consumer;" { | ||
MethodType "(Ljava/lang/Object;)V", | ||
MethodHandle REF_invokeVirtual:#1, | ||
MethodType "(Ljava/lang/Integer;)V" | ||
}; | ||
invokevirtual Method visit:"(Ljava/util/function/Consumer;)V"; | ||
return; | ||
|
||
} | ||
public Method visit:"(Ljava/util/function/Consumer;)V" | ||
stack 2 locals 2 | ||
{ | ||
aload_1; | ||
ldc String "Foo"; | ||
invokevirtual Method java/lang/String.hashCode:"()I"; | ||
invokestatic Method java/lang/Integer.valueOf:"(I)Ljava/lang/Integer;"; | ||
invokeinterface InterfaceMethod java/util/function/Consumer.accept:"(Ljava/lang/Object;)V", 2; | ||
aload_1; | ||
ldc String "Bar"; | ||
invokevirtual Method java/lang/String.length:"()I"; | ||
invokestatic Method java/lang/Integer.valueOf:"(I)Ljava/lang/Integer;"; | ||
invokeinterface InterfaceMethod java/util/function/Consumer.accept:"(Ljava/lang/Object;)V", 2; | ||
return; | ||
|
||
} | ||
public Method accept:"(Ljava/lang/Number;)Ljava/lang/Number;" | ||
stack 2 locals 2 | ||
{ | ||
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;"; | ||
aload_1; | ||
invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/Object;)V"; | ||
aload_1; | ||
areturn; | ||
|
||
} | ||
private synthetic Method lambda$init$0:"(Ljava/lang/Integer;)V" | ||
stack 2 locals 2 | ||
{ | ||
aload_0; | ||
aload_1; | ||
invokevirtual Method accept:"(Ljava/lang/Number;)Ljava/lang/Number;"; | ||
checkcast java/lang/Integer; // No idea why javac would compile this checkcast | ||
pop; | ||
return; | ||
|
||
} | ||
|
||
public static final InnerClass Lookup=class java/lang/invoke/MethodHandles$Lookup of class java/lang/invoke/MethodHandles; | ||
|
||
} // end Class TestMissingLambdaBody |