Skip to content

Instantly share code, notes, and snippets.

@radarek
Created February 6, 2017 10:55
Show Gist options
  • Save radarek/8c3fcc0ec5765746c1227a10a5515c77 to your computer and use it in GitHub Desktop.
Save radarek/8c3fcc0ec5765746c1227a10a5515c77 to your computer and use it in GitHub Desktop.
class Hello {
public static String helloString = "Hello World!";
public static void main(String[] args) {
System.out.println(helloString);
foo();
}
public static void foo() {
System.out.println("Foo called");
}
}
$ javac Hello.java
$ javap -c Hello
Compiled from "Hello.java"
class Hello {
public static java.lang.String helloString;
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: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
3: getstatic #3 // Field helloString:Ljava/lang/String;
6: invokevirtual #4 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
9: invokestatic #5 // Method foo:()V
12: return
public static void foo();
Code:
0: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #6 // String Foo called
5: invokevirtual #4 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: return
static {};
Code:
0: ldc #7 // String Hello World!
2: putstatic #3 // Field helloString:Ljava/lang/String;
5: return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment