Skip to content

Instantly share code, notes, and snippets.

@oscarryz
Created April 14, 2014 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarryz/10668791 to your computer and use it in GitHub Desktop.
Save oscarryz/10668791 to your computer and use it in GitHub Desktop.
$cat Hello.java
class Hello {
public static void main(String ... args) {
runIt( () -> System.out.println("Hello") );
}
public static void runIt( Runnable r ) {
r.run();
}
}
$javac Hello.java
$javap -c Hello
Compiled from "Hello.java"
class Hello {
Hello();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String...);
Code:
0: invokedynamic #2, 0 // InvokeDynamic #0:run:()Ljava/lang/Runnable;
5: invokestatic #3 // Method runIt:(Ljava/lang/Runnable;)V
8: return
public static void runIt(java.lang.Runnable);
Code:
0: aload_0
1: invokeinterface #4, 1 // InterfaceMethod java/lang/Runnable.run:()V
6: return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment