Skip to content

Instantly share code, notes, and snippets.

@MinCha
Created December 4, 2013 09:18
Show Gist options
  • Save MinCha/7784650 to your computer and use it in GitHub Desktop.
Save MinCha/7784650 to your computer and use it in GitHub Desktop.
Java Byte Code when doing auto-boxing
@Test
public void autoBoxing() {
Long v = 555L;
v = v + 2;
v = v + 3;
System.out.println(v);
}
@Test
public void autoBoxing2() {
long v = 555L;
v = v + 2;
v = v + 3;
System.out.println(v);
}
public void autoBoxing();
0 ldc2_w <Long 555> [74]
3 invokestatic java.lang.Long.valueOf(long) : java.lang.Long [76]
6 astore_1 [v]
7 aload_1 [v]
8 invokevirtual java.lang.Long.longValue() : long [81]
11 ldc2_w <Long 2> [85]
14 ladd
15 invokestatic java.lang.Long.valueOf(long) : java.lang.Long [76]
18 astore_1 [v]
19 aload_1 [v]
20 invokevirtual java.lang.Long.longValue() : long [81]
23 ldc2_w <Long 3> [87]
26 ladd
27 invokestatic java.lang.Long.valueOf(long) : java.lang.Long [76]
30 astore_1 [v]
31 getstatic java.lang.System.out : java.io.PrintStream [59]
34 aload_1 [v]
35 invokevirtual java.io.PrintStream.println(java.lang.Object) : void [89]
38 return
public void autoBoxing2();
0 ldc2_w <Long 555> [74]
3 lstore_1 [v]
4 lload_1 [v]
5 ldc2_w <Long 2> [85]
8 ladd
9 lstore_1 [v]
10 lload_1 [v]
11 ldc2_w <Long 3> [87]
14 ladd
15 lstore_1 [v]
16 getstatic java.lang.System.out : java.io.PrintStream [59]
19 lload_1 [v]
20 invokevirtual java.io.PrintStream.println(long) : void [95]
23 return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment