public static byte [ ] toByteArray ( Object obj ) { int len = ( int ) sizeOf ( obj ) ; byte [ ] bytes = new byte [ len ] ; unsafe . copyMemory ( obj , 0 , bytes , Unsafe . ARRAY_BYTE_BASE_OFFSET , bytes . length ) ; return bytes ; }
Returns the object as a byte array including header padding and all fields .