java学习常用辅助工具总结

1. java对象结构查看-JOL

描述:openjdk提供的一个查看java对象的小工具
官网:jol官网链接
基本用法

  • 引入maven
        
        
            org.openjdk.jol
            jol-core
            0.10
        
  • 打印对象
public static void main(String[] args) {
        Object obj = new Object();
        System.out.println(ClassLayout.parseInstance(obj).toPrintable());
    }
  • 查看结果
java.lang.Object object internals:
 OFFSET  SIZE   TYPE DESCRIPTION                               VALUE
      0     4        (object header)                           01 00 00 00 (00000001 00000000 00000000 00000000) (1)
      4     4        (object header)                           00 00 00 00 (00000000 00000000 00000000 00000000) (0)
      8     4        (object header)                           28 0f 96 16 (00101000 00001111 10010110 00010110) (378933032)
     12     4        (loss due to the next object alignment)
Instance size: 16 bytes
Space losses: 0 bytes internal + 4 bytes external = 4 bytes total

(持续更新......)

你可能感兴趣的:(java学习常用辅助工具总结)