Skip to content

Instantly share code, notes, and snippets.

@vaskoz
Last active December 19, 2015 12:28
Show Gist options
  • Save vaskoz/5954838 to your computer and use it in GitHub Desktop.
Save vaskoz/5954838 to your computer and use it in GitHub Desktop.
Only gets used when calling a method on an object from an Interface type.
public class InvokeInterface {
public void methodA() {
Runnable r = new Runnable() {
@Override public void run() {}
};
r.run();
}
}
//Compiled from "InvokeInterface.java"
//public class InvokeInterface {
// public InvokeInterface();
// Code:
// 0: aload_0
// 1: invokespecial #1 // Method java/lang/Object."<init>":()V
// 4: return
//
// public void methodA();
// Code:
// 0: new #2 // class InvokeInterface$1
// 3: dup
// 4: aload_0
// 5: invokespecial #3 // Method InvokeInterface$1."<init>":(LInvokeInterface;)V
// 8: astore_1
// 9: aload_1
// 10: invokeinterface #4, 1 // InterfaceMethod java/lang/Runnable.run:()V
// 15: return
//}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment