-
Notifications
You must be signed in to change notification settings - Fork 4
Java Bytecode
Ahmed Yakout edited this page May 5, 2018
·
3 revisions
How to generate Byte-code from java code:
javac Main.java
javap -c Main
Example:
import java.lang.*;
public class Main
{
public static void main(String[] arg)
{
int i = 1;
int j = i + 1;
while (j > 0) {
j--;
}
// System.out.println("Hello World!");
}
}
generated bytecode:
Compiled from "Main.java"
public class Main {
public Main();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: iconst_1
1: istore_1
2: iload_1
3: iconst_1
4: iadd
5: istore_2
6: iload_2
7: ifle 16
10: iinc 2, -1
13: goto 6
16: return
}