1

Is there a way to get the bytes of an object that doesn't implement serializeble? In cpp i know you can just copy size of the object bytes from the address of the object in the memory, is there a way to do this in java?

edit: I don't really see how that is a duplication of Converting any object to a byte array in java by just to clarify i meant convert a specific non serilizable object

Community
  • 1
  • 1
kill129
  • 100
  • 10

2 Answers2

1

No, it isn't possible to get the raw bytes of an object. Java doesn't have such a view of the world, where objects even have an underlying byte representation.

Note that serialization doesn't give you access to the byte representation of an object either. Serialization is a way of encoding the information in an object into a byte array. It doesn't give you the raw bytes. If you somehow searched through memory for those serialized bytes you wouldn't find them.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
0

Probably not and most likely because Serialization is a Java mechanism that provides a representation in bytes of values, types and parameter types. I recommend you read this introduction to serialization.