Last active
December 16, 2015 14:09
-
-
Save msfroh/5447075 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
final class example.AnonymousFunction$1 implements java.util.function.Function<java.lang.Integer, java.lang.Integer> { | |
final java.lang.Integer val$i; | |
example.AnonymousFunction$1(java.lang.Integer); | |
public java.lang.Integer apply(java.lang.Integer); | |
public java.lang.Object apply(java.lang.Object); | |
} |
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
public class AnonymousFunction { | |
public static void main(String[] args) { | |
final Integer i = Integer.valueOf(args[0]); | |
Function<Integer, Integer> addi = new Function<Integer, Integer>() { | |
@Override | |
public Integer apply(final Integer n) { | |
return n + i; | |
} | |
}; | |
System.out.println(addi.apply(5)); | |
} | |
} |
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
AnonymousFunction$1.class 1033 | |
AnonymousFunction.class 1099 | |
InnerClassFunction$One.class 1000 | |
InnerClassFunction.class 1112 | |
SimpleLambda.class 1701 |
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
public class InnerClassFunction { | |
public static void main(String[] args) { | |
final Integer i = Integer.valueOf(args[0]); | |
Function<Integer, Integer> addi = new One(i); | |
System.out.println(addi.apply(5)); | |
} | |
private static final class One implements Function<Integer, Integer> { | |
final Integer valI; | |
One(final Integer i) { | |
valI = i; | |
} | |
@Override | |
public Integer apply(final Integer n) { | |
return n + valI; | |
} | |
} | |
} |
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
public class SimpleLambda { | |
public static void main(String[] args) { | |
final Integer i = Integer.valueOf(args[0]); | |
Function<Integer, Integer> addi = (n) -> n + i; | |
System.out.println(addi.apply(5)); | |
} | |
} |
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
BootstrapMethods: | |
0: #36 invokestatic java/lang/invoke/LambdaMetafactory.metaFactory:(Ljava/lang/invoke/MethodHandles$Lookup; | |
Ljava/lang/String; | |
Ljava/lang/invoke/MethodType; | |
Ljava/lang/invoke/MethodHandle; | |
Ljava/lang/invoke/MethodHandle; | |
Ljava/lang/invoke/MethodType;) | |
Ljava/lang/invoke/CallSite; | |
Method arguments: | |
#37 invokeinterface java/util/function/Function.apply:(Ljava/lang/Object;)Ljava/lang/Object; | |
#38 invokestatic example/SimpleLambda.lambda$6:(Ljava/lang/Integer;Ljava/lang/Integer;)Ljava/lang/Integer; | |
#39 (Ljava/lang/Integer;)Ljava/lang/Integer; |
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
public static void main(java.lang.String[]); | |
flags: ACC_PUBLIC, ACC_STATIC | |
Code: | |
stack=3, locals=3, args_size=1 | |
0: aload_0 | |
1: iconst_0 | |
2: aaload | |
3: invokestatic #2 // Method java/lang/Integer.valueOf:(Ljava/lang/String;)Ljava/lang/Integer; | |
6: astore_1 | |
7: aload_1 | |
8: invokedynamic #3, 0 // InvokeDynamic #0:lambda$:(Ljava/lang/Integer;)Ljava/util/function/Function; | |
13: astore_2 | |
14: getstatic #4 // Field java/lang/System.out:Ljava/io/PrintStream; | |
17: aload_2 | |
18: iconst_5 | |
19: invokestatic #5 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; | |
22: invokeinterface #6, 2 // InterfaceMethod java/util/function/Function.apply:(Ljava/lang/Object;)Ljava/lang/Object; | |
27: invokevirtual #7 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V | |
30: return |
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
public class TracingSimpleLambda { | |
public static void main(String[] args) { | |
final Integer i = Integer.valueOf(args[0]); | |
Function<Integer, Integer> addi = (n) -> { | |
System.out.println("Here is a stacktrace from the addi call:"); | |
new Exception().printStackTrace(); | |
return n + i; | |
}; | |
System.out.println("TracingSimpleLambda has the following methods:"); | |
for (Method method: TracingSimpleLambda.class.getDeclaredMethods()) { | |
System.out.println(" " + method); | |
} | |
System.out.println("addi's classname is " + | |
addi.getClass().getCanonicalName()); | |
System.out.println("addi's class has the following fields:"); | |
for (Field field : addi.getClass().getDeclaredFields()) { | |
System.out.println(" " + field); | |
} | |
System.out.println("addi's class has the following constructors:"); | |
for (Constructor<?> constructor : addi.getClass().getDeclaredConstructors()) { | |
System.out.println(" " + constructor); | |
} | |
System.out.println("addi's class has the following methods:"); | |
for (Method method : addi.getClass().getDeclaredMethods()) { | |
System.out.println(" " + method); | |
} | |
System.out.println(addi.apply(5)); | |
} | |
} |
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
TracingSimpleLambda has the following methods: | |
public static void example.TracingSimpleLambda.main(java.lang.String[]) | |
private static java.lang.Integer example.TracingSimpleLambda.lambda$0(java.lang.Integer,java.lang.Integer) | |
addi's classname is example.TracingSimpleLambda$$Lambda$1 | |
addi's class has the following fields: | |
private final java.lang.Integer example.TracingSimpleLambda$$Lambda$1.arg$1 | |
addi's class has the following constructors: | |
private example.TracingSimpleLambda$$Lambda$1(java.lang.Integer) | |
addi's class has the following methods: | |
public java.lang.Object example.TracingSimpleLambda$$Lambda$1.apply(java.lang.Object) | |
Here is a stacktrace from the addi call: | |
java.lang.Exception | |
at example.TracingSimpleLambda.lambda$0(TracingSimpleLambda.java:18) | |
at example.TracingSimpleLambda$$Lambda$1.apply(Unknown Source) | |
at example.TracingSimpleLambda.main(TracingSimpleLambda.java:40) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment