Last active
August 29, 2015 14:05
-
-
Save jeremyheiler/969da4be50b491b1d37c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class B { | |
public Object lock = new Object(); | |
public String foo() { | |
return "foo"; | |
} | |
public synchronized String bar() { | |
return "bar"; | |
} | |
public String baz() { | |
synchronized(this) { | |
return "baz"; | |
} | |
} | |
public String boo() { | |
synchronized(lock) { | |
return "boo"; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// output of: javac B.java && javap -v B | |
Classfile /home/jeremy/src/jeremyheiler/asm/B.class | |
Last modified Aug 11, 2014; size 628 bytes | |
MD5 checksum 0b6c86d38f9f75eb4ba1d721c4c29874 | |
Compiled from "B.java" | |
public class B | |
SourceFile: "B.java" | |
minor version: 0 | |
major version: 51 | |
flags: ACC_PUBLIC, ACC_SUPER | |
Constant pool: | |
#1 = Methodref #2.#26 // java/lang/Object."<init>":()V | |
#2 = Class #27 // java/lang/Object | |
#3 = Fieldref #8.#28 // B.lock:Ljava/lang/Object; | |
#4 = String #15 // foo | |
#5 = String #17 // bar | |
#6 = String #18 // baz | |
#7 = String #23 // boo | |
#8 = Class #29 // B | |
#9 = Utf8 lock | |
#10 = Utf8 Ljava/lang/Object; | |
#11 = Utf8 <init> | |
#12 = Utf8 ()V | |
#13 = Utf8 Code | |
#14 = Utf8 LineNumberTable | |
#15 = Utf8 foo | |
#16 = Utf8 ()Ljava/lang/String; | |
#17 = Utf8 bar | |
#18 = Utf8 baz | |
#19 = Utf8 StackMapTable | |
#20 = Class #29 // B | |
#21 = Class #27 // java/lang/Object | |
#22 = Class #30 // java/lang/Throwable | |
#23 = Utf8 boo | |
#24 = Utf8 SourceFile | |
#25 = Utf8 B.java | |
#26 = NameAndType #11:#12 // "<init>":()V | |
#27 = Utf8 java/lang/Object | |
#28 = NameAndType #9:#10 // lock:Ljava/lang/Object; | |
#29 = Utf8 B | |
#30 = Utf8 java/lang/Throwable | |
{ | |
public java.lang.Object lock; | |
flags: ACC_PUBLIC | |
public B(); | |
flags: ACC_PUBLIC | |
Code: | |
stack=3, locals=1, args_size=1 | |
0: aload_0 | |
1: invokespecial #1 // Method java/lang/Object."<init>":()V | |
4: aload_0 | |
5: new #2 // class java/lang/Object | |
8: dup | |
9: invokespecial #1 // Method java/lang/Object."<init>":()V | |
12: putfield #3 // Field lock:Ljava/lang/Object; | |
15: return | |
LineNumberTable: | |
line 1: 0 | |
line 3: 4 | |
public java.lang.String foo(); | |
flags: ACC_PUBLIC | |
Code: | |
stack=1, locals=1, args_size=1 | |
0: ldc #4 // String foo | |
2: areturn | |
LineNumberTable: | |
line 6: 0 | |
public synchronized java.lang.String bar(); | |
flags: ACC_PUBLIC, ACC_SYNCHRONIZED | |
Code: | |
stack=1, locals=1, args_size=1 | |
0: ldc #5 // String bar | |
2: areturn | |
LineNumberTable: | |
line 10: 0 | |
public java.lang.String baz(); | |
flags: ACC_PUBLIC | |
Code: | |
stack=2, locals=3, args_size=1 | |
0: aload_0 | |
1: dup | |
2: astore_1 | |
3: monitorenter | |
4: ldc #6 // String baz | |
6: aload_1 | |
7: monitorexit | |
8: areturn | |
9: astore_2 | |
10: aload_1 | |
11: monitorexit | |
12: aload_2 | |
13: athrow | |
Exception table: | |
from to target type | |
4 8 9 any | |
9 12 9 any | |
LineNumberTable: | |
line 14: 0 | |
line 15: 4 | |
line 16: 9 | |
StackMapTable: number_of_entries = 1 | |
frame_type = 255 /* full_frame */ | |
offset_delta = 9 | |
locals = [ class B, class java/lang/Object ] | |
stack = [ class java/lang/Throwable ] | |
public java.lang.String boo(); | |
flags: ACC_PUBLIC | |
Code: | |
stack=2, locals=3, args_size=1 | |
0: aload_0 | |
1: getfield #3 // Field lock:Ljava/lang/Object; | |
4: dup | |
5: astore_1 | |
6: monitorenter | |
7: ldc #7 // String boo | |
9: aload_1 | |
10: monitorexit | |
11: areturn | |
12: astore_2 | |
13: aload_1 | |
14: monitorexit | |
15: aload_2 | |
16: athrow | |
Exception table: | |
from to target type | |
7 11 12 any | |
12 15 12 any | |
LineNumberTable: | |
line 20: 0 | |
line 21: 7 | |
line 22: 12 | |
StackMapTable: number_of_entries = 1 | |
frame_type = 255 /* full_frame */ | |
offset_delta = 12 | |
locals = [ class B, class java/lang/Object ] | |
stack = [ class java/lang/Throwable ] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment