public static void printMemoryLayout2 ( ) { Object o1 = new Object ( ) ; Object o2 = new Object ( ) ; Byte b1 = new Byte ( ( byte ) 0x12 ) ; Byte b2 = new Byte ( ( byte ) 0x34 ) ; Byte b3 = new Byte ( ( byte ) 0x56 ) ; Long l = new Long ( 0x0123456789ABCDEF L ) ; Person p = new Person ( "Bob" , 406425600000L , ' ' ) ; System . out . printf ( "Object len:%d header:%d\n" , UnsafeHelper . sizeOf ( o1 ) , UnsafeHelper . headerSize ( o1 ) ) ; UnsafeHelper . hexDump ( System . out , o1 ) ; UnsafeHelper . hexDump ( System . out , o2 ) ; System . out . printf ( "Byte len:%d header:%d\n" , UnsafeHelper . sizeOf ( b1 ) , UnsafeHelper . headerSize ( b1 ) ) ; UnsafeHelper . hexDump ( System . out , b1 ) ; UnsafeHelper . hexDump ( System . out , b2 ) ; UnsafeHelper . hexDump ( System . out , b3 ) ; Byte [ ] bArray0 = new Byte [ ] { } ; Byte [ ] bArray1 = new Byte [ ] { b1 } ; Byte [ ] bArray2 = new Byte [ ] { b1 , b2 } ; Byte [ ] bArray3 = new Byte [ ] { b1 , b2 , b3 } ; System . out . printf ( "Byte[0] len:%d header:%d\n" , UnsafeHelper . sizeOf ( bArray0 ) , UnsafeHelper . headerSize ( bArray0 ) ) ; UnsafeHelper . hexDump ( System . out , bArray0 ) ; System . out . printf ( "Byte[1] len:%d header:%d\n" , UnsafeHelper . sizeOf ( bArray1 ) , UnsafeHelper . headerSize ( bArray1 ) ) ; UnsafeHelper . hexDump ( System . out , bArray1 ) ; System . out . printf ( "Byte[2] len:%d header:%d\n" , UnsafeHelper . sizeOf ( bArray2 ) , UnsafeHelper . headerSize ( bArray2 ) ) ; UnsafeHelper . hexDump ( System . out , bArray2 ) ; System . out . printf ( "Byte[3] len:%d header:%d\n" , UnsafeHelper . sizeOf ( bArray3 ) , UnsafeHelper . headerSize ( bArray3 ) ) ; UnsafeHelper . hexDump ( System . out , bArray3 ) ; System . out . printf ( "Long len:%d header:%d\n" , UnsafeHelper . sizeOf ( l ) , UnsafeHelper . headerSize ( l ) ) ; UnsafeHelper . hexDump ( System . out , l ) ; System . out . printf ( "Person len:%d header:%d\n" , UnsafeHelper . sizeOf ( p ) , UnsafeHelper . headerSize ( p ) ) ; UnsafeHelper . hexDump ( System . out , p ) ; }
Prints the memory layout of various test classes .