Created
November 16, 2011 12:45
-
-
Save nahi/1369995 to your computer and use it in GitHub Desktop.
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
import java.util.*; | |
public class G { | |
interface F { | |
int calc(int x); | |
} | |
public static void main(String[] args) { | |
F fib = (x) -> (x < 2) ? x : fib.calc(x - 1) + fib.calc(x - 2); // fibonacci | |
Comparator<String> reverse = (a, b) -> -1; // reverse sort | |
int r = fib.calc(10); | |
String[] list = { "a", "b", "c" }; | |
Arrays.sort(list, reverse); | |
} | |
} |
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
% ~/java/lambda_b1314/bin/javac G.java | |
% ~/java/lambda_b1314/bin/javap -v G 'G$1' 'G$2' | |
Classfile /home/nahi/git/lambda-sandbox/G.class | |
Last modified Nov 16, 2011; size 567 bytes | |
MD5 checksum 59cc085a9dc28fc2753540686bcc2250 | |
Compiled from "G.java" | |
public class G | |
SourceFile: "G.java" | |
InnerClasses: | |
static #15= #14 of #12; //F=class G$F of class G | |
static #4; //class G$2 | |
static #2; //class G$1 | |
minor version: 0 | |
major version: 51 | |
flags: ACC_PUBLIC, ACC_SUPER | |
Constant pool: | |
#1 = Methodref #13.#26 // java/lang/Object."<init>":()V | |
#2 = Class #27 // G$1 | |
#3 = Methodref #2.#26 // G$1."<init>":()V | |
#4 = Class #28 // G$2 | |
#5 = Methodref #4.#26 // G$2."<init>":()V | |
#6 = InterfaceMethodref #14.#29 // G$F.calc:(I)I | |
#7 = Class #30 // java/lang/String | |
#8 = String #31 // a | |
#9 = String #32 // b | |
#10 = String #33 // c | |
#11 = Methodref #34.#35 // java/util/Arrays.sort:([Ljava/lang/Object;Ljava/util/Comparator;)V | |
#12 = Class #36 // G | |
#13 = Class #37 // java/lang/Object | |
#14 = Class #38 // G$F | |
#15 = Utf8 F | |
#16 = Utf8 InnerClasses | |
#17 = Utf8 | |
#18 = Utf8 <init> | |
#19 = Utf8 ()V | |
#20 = Utf8 Code | |
#21 = Utf8 LineNumberTable | |
#22 = Utf8 main | |
#23 = Utf8 ([Ljava/lang/String;)V | |
#24 = Utf8 SourceFile | |
#25 = Utf8 G.java | |
#26 = NameAndType #18:#19 // "<init>":()V | |
#27 = Utf8 G$1 | |
#28 = Utf8 G$2 | |
#29 = NameAndType #39:#40 // calc:(I)I | |
#30 = Utf8 java/lang/String | |
#31 = Utf8 a | |
#32 = Utf8 b | |
#33 = Utf8 c | |
#34 = Class #41 // java/util/Arrays | |
#35 = NameAndType #42:#43 // sort:([Ljava/lang/Object;Ljava/util/Comparator;)V | |
#36 = Utf8 G | |
#37 = Utf8 java/lang/Object | |
#38 = Utf8 G$F | |
#39 = Utf8 calc | |
#40 = Utf8 (I)I | |
#41 = Utf8 java/util/Arrays | |
#42 = Utf8 sort | |
#43 = Utf8 ([Ljava/lang/Object;Ljava/util/Comparator;)V | |
{ | |
public G(); | |
flags: ACC_PUBLIC | |
Code: | |
stack=1, locals=1, args_size=1 | |
0: aload_0 | |
1: invokespecial #1 // Method java/lang/Object."<init>":()V | |
4: return | |
LineNumberTable: | |
line 3: 0 | |
line 5: 4 | |
public static void main(java.lang.String[]); | |
flags: ACC_PUBLIC, ACC_STATIC | |
Code: | |
stack=4, locals=5, args_size=1 | |
0: new #2 // class G$1 | |
3: dup | |
4: invokespecial #3 // Method G$1."<init>":()V | |
7: astore_1 | |
8: new #4 // class G$2 | |
11: dup | |
12: invokespecial #5 // Method G$2."<init>":()V | |
15: astore_2 | |
16: aload_1 | |
17: bipush 10 | |
19: invokeinterface #6, 2 // InterfaceMethod G$F.calc:(I)I | |
24: istore_3 | |
25: iconst_3 | |
26: anewarray #7 // class java/lang/String | |
29: dup | |
30: iconst_0 | |
31: ldc #8 // String a | |
33: aastore | |
34: dup | |
35: iconst_1 | |
36: ldc #9 // String b | |
38: aastore | |
39: dup | |
40: iconst_2 | |
41: ldc #10 // String c | |
43: aastore | |
44: astore 4 | |
46: aload 4 | |
48: aload_2 | |
49: invokestatic #11 // Method java/util/Arrays.sort:([Ljava/lang/Object;Ljava/util/Comparator;)V | |
52: return | |
LineNumberTable: | |
line 10: 0 | |
line 11: 8 | |
line 12: 16 | |
line 13: 25 | |
line 14: 46 | |
line 15: 52 | |
} | |
Classfile /home/nahi/git/lambda-sandbox/G$1.class | |
Last modified Nov 16, 2011; size 425 bytes | |
MD5 checksum 07f691b6c2a19fb5aa2fc4e9fc77d607 | |
Compiled from "G.java" | |
class G$1 implements G$F | |
SourceFile: "G.java" | |
EnclosingMethod: #16.#17 // G.main | |
InnerClasses: | |
static #3; //class G$1 | |
static #25= #5 of #16; //F=class G$F of class G | |
minor version: 0 | |
major version: 51 | |
flags: ACC_SUPER, ACC_SYNTHETIC | |
Constant pool: | |
#1 = Methodref #4.#18 // java/lang/Object."<init>":()V | |
#2 = InterfaceMethodref #5.#19 // G$F.calc:(I)I | |
#3 = Class #20 // G$1 | |
#4 = Class #23 // java/lang/Object | |
#5 = Class #24 // G$F | |
#6 = Utf8 <init> | |
#7 = Utf8 ()V | |
#8 = Utf8 Code | |
#9 = Utf8 LineNumberTable | |
#10 = Utf8 calc | |
#11 = Utf8 (I)I | |
#12 = Utf8 StackMapTable | |
#13 = Utf8 SourceFile | |
#14 = Utf8 G.java | |
#15 = Utf8 EnclosingMethod | |
#16 = Class #26 // G | |
#17 = NameAndType #27:#28 // main:([Ljava/lang/String;)V | |
#18 = NameAndType #6:#7 // "<init>":()V | |
#19 = NameAndType #10:#11 // calc:(I)I | |
#20 = Utf8 G$1 | |
#21 = Utf8 | |
#22 = Utf8 InnerClasses | |
#23 = Utf8 java/lang/Object | |
#24 = Utf8 G$F | |
#25 = Utf8 F | |
#26 = Utf8 G | |
#27 = Utf8 main | |
#28 = Utf8 ([Ljava/lang/String;)V | |
{ | |
G$1(); | |
flags: | |
Code: | |
stack=1, locals=1, args_size=1 | |
0: aload_0 | |
1: invokespecial #1 // Method java/lang/Object."<init>":()V | |
4: return | |
LineNumberTable: | |
line 1: 0 | |
public int calc(int); | |
flags: ACC_PUBLIC, ACC_SYNTHETIC | |
Code: | |
stack=4, locals=2, args_size=2 | |
0: iload_1 | |
1: iconst_2 | |
2: if_icmpge 9 | |
5: iload_1 | |
6: goto 28 | |
9: aload_0 | |
10: iload_1 | |
11: iconst_1 | |
12: isub | |
13: invokeinterface #2, 2 // InterfaceMethod G$F.calc:(I)I | |
18: aload_0 | |
19: iload_1 | |
20: iconst_2 | |
21: isub | |
22: invokeinterface #2, 2 // InterfaceMethod G$F.calc:(I)I | |
27: iadd | |
28: ireturn | |
LineNumberTable: | |
line 10: 0 | |
StackMapTable: number_of_entries = 2 | |
frame_type = 9 /* same */ | |
frame_type = 82 /* same_locals_1_stack_item */ | |
stack = [ int ] | |
} | |
Classfile /home/nahi/git/lambda-sandbox/G$2.class | |
Last modified Nov 16, 2011; size 612 bytes | |
MD5 checksum 27dc6b0b33a16878ebedcbed5e27449e | |
Compiled from "G.java" | |
class G$2 extends java.lang.Object implements java.util.Comparator<java.lang.String> | |
Signature: #15 // Ljava/lang/Object;Ljava/util/Comparator<Ljava/lang/String;>; | |
SourceFile: "G.java" | |
EnclosingMethod: #19.#20 // G.main | |
InnerClasses: | |
static #4; //class G$2 | |
minor version: 0 | |
major version: 51 | |
flags: ACC_SUPER, ACC_SYNTHETIC | |
Constant pool: | |
#1 = Class #21 // java/lang/String | |
#2 = Methodref #4.#22 // G$2.compare:(Ljava/lang/String;Ljava/lang/String;)I | |
#3 = Methodref #5.#23 // java/lang/Object."<init>":()V | |
#4 = Class #24 // G$2 | |
#5 = Class #27 // java/lang/Object | |
#6 = Class #28 // java/util/Comparator | |
#7 = Utf8 <init> | |
#8 = Utf8 ()V | |
#9 = Utf8 Code | |
#10 = Utf8 LineNumberTable | |
#11 = Utf8 compare | |
#12 = Utf8 (Ljava/lang/String;Ljava/lang/String;)I | |
#13 = Utf8 (Ljava/lang/Object;Ljava/lang/Object;)I | |
#14 = Utf8 Signature | |
#15 = Utf8 Ljava/lang/Object;Ljava/util/Comparator<Ljava/lang/String;>; | |
#16 = Utf8 SourceFile | |
#17 = Utf8 G.java | |
#18 = Utf8 EnclosingMethod | |
#19 = Class #29 // G | |
#20 = NameAndType #30:#31 // main:([Ljava/lang/String;)V | |
#21 = Utf8 java/lang/String | |
#22 = NameAndType #11:#12 // compare:(Ljava/lang/String;Ljava/lang/String;)I | |
#23 = NameAndType #7:#8 // "<init>":()V | |
#24 = Utf8 G$2 | |
#25 = Utf8 | |
#26 = Utf8 InnerClasses | |
#27 = Utf8 java/lang/Object | |
#28 = Utf8 java/util/Comparator | |
#29 = Utf8 G | |
#30 = Utf8 main | |
#31 = Utf8 ([Ljava/lang/String;)V | |
{ | |
G$2(); | |
flags: | |
Code: | |
stack=1, locals=1, args_size=1 | |
0: aload_0 | |
1: invokespecial #3 // Method java/lang/Object."<init>":()V | |
4: return | |
LineNumberTable: | |
line 10: 0 | |
public int compare(java.lang.String, java.lang.String); | |
flags: ACC_PUBLIC, ACC_SYNTHETIC | |
Code: | |
stack=1, locals=3, args_size=3 | |
0: iconst_m1 | |
1: ireturn | |
LineNumberTable: | |
line 11: 0 | |
public int compare(java.lang.Object, java.lang.Object); | |
flags: ACC_PUBLIC, ACC_BRIDGE, ACC_SYNTHETIC | |
Code: | |
stack=3, locals=3, args_size=3 | |
0: aload_0 | |
1: aload_1 | |
2: checkcast #1 // class java/lang/String | |
5: aload_2 | |
6: checkcast #1 // class java/lang/String | |
9: invokevirtual #2 // Method compare:(Ljava/lang/String;Ljava/lang/String;)I | |
12: ireturn | |
LineNumberTable: | |
line 10: 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment