Skip to content

Commit e6c31c9

Browse files
committed
2022年05月20日
1 parent 3129cfb commit e6c31c9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

jdk/src/main/java/com/tenstone/jdk/juc/locks/JOLObjectHeaderDemo.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
@Slf4j
1111
public class JOLObjectHeaderDemo {
1212

13+
static class TestObj{
14+
private long p1;
15+
private byte p2;
16+
private long p3;
17+
private long p4;
18+
}
19+
1320
/**
1421
* 对象头
1522
* 1. mark word (8 bytes) hashCode,锁标志位,gc年龄
@@ -19,6 +26,7 @@ public class JOLObjectHeaderDemo {
1926
* @param args
2027
*/
2128
public static void main(String[] args) {
29+
final TestObj testObj = new TestObj();
2230
log.debug("\n=========================================VM.current.details()====================================");
2331
log.debug("{}", VM.current().details());
2432
log.debug("\n=========================================String.class============================================");
@@ -30,6 +38,6 @@ public static void main(String[] args) {
3038
hello.hashCode();
3139
log.debug("{}", ClassLayout.parseInstance(hello).toPrintable());
3240
log.debug("\n=========================================empty String============================================");
33-
log.debug("{}", ClassLayout.parseInstance("").toPrintable());
41+
log.debug("{}", ClassLayout.parseInstance(testObj).toPrintable());
3442
}
3543
}

0 commit comments

Comments
 (0)