Last active
January 6, 2016 14:20
-
-
Save edwardbeckett/9716bd8f8ec79a53cc2e to your computer and use it in GitHub Desktop.
Lambda Scope
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
/** | |
* javap -c SimpleFunction.class | |
*/ | |
Compiled from "SimpleFunction.java" | |
public class com.beckett.lambdas.SimpleFunction { | |
static java.util.function.Function<java.lang.Integer, java.lang.Integer> f; | |
public com.beckett.lambdas.SimpleFunction(); | |
Code: | |
0: aload_0 | |
1: invokespecial #1 // Method java/lang/Object."<init>":()V | |
4: return | |
public static void main(java.lang.String[]); | |
Code: | |
0: getstatic #2 // Field f:Ljava/util/function/Function; | |
3: iconst_0 | |
4: invokestatic #3 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; | |
7: invokeinterface #4, 2 // InterfaceMethod java/util/function/Function.apply:(Ljava/lang/Object;)Ljava/lang/Object; | |
12: checkcast #5 // class java/lang/Integer | |
15: invokevirtual #6 // Method java/lang/Integer.intValue:()I | |
18: istore_1 | |
19: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream; | |
22: iload_1 | |
23: invokevirtual #8 // Method java/io/PrintStream.println:(I)V | |
26: return | |
static {}; | |
Code: | |
0: invokedynamic #9, 0 // InvokeDynamic #0:apply:()Ljava/util/function/Function; | |
5: putstatic #2 // Field f:Ljava/util/function/Function; | |
8: 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
package com.beckett.lambdas; | |
import java.util.function.Function; | |
public class SimpleFunction { | |
static Function<Integer, Integer> f = i -> ++i; | |
public static void main(String[] args) { | |
int i = f.apply(0); | |
System.out.println(i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment