Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java's Representation of Serialized Objects

I'm looking for the format that Java uses to serialize objects. The default serialization serializes the object in a binary format. In particular, I'm curious to know if two runs of a program can serialize the same object differently.

What condition should an object satisfy so that the object maintains its behavior under Java's default serialization/deserialization round-trip?

like image 540
reprogrammer Avatar asked Sep 30 '09 23:09

reprogrammer


People also ask

Which method is used for object serialization?

The ObjectOutputStream class contains writeObject() method for serializing an Object. The ObjectInputStream class contains readObject() method for deserializing an object.

What does serializing an object mean?

To serialize an object means to convert its state to a byte stream so way that the byte stream can be reverted back into a copy of the object. A Java object is serializable if its class or any of its superclasses implements either the java. io. Serializable interface or its subinterface, java.

What is the role of SerialVersionUID in serialization process?

SerialVersionUID is a unique identifier for each class, JVM uses it to compare the versions of the class ensuring that the same class was used during Serialization is loaded during Deserialization.

Is SerialVersionUID serialized?

The serialVersionUID attribute is an identifier that is used to serialize/deserialize an object of a Serializable class.


1 Answers

You need the Java Object Serialization Specification at http://java.sun.com/javase/6/docs/platform/serialization/spec/protocol.html.

like image 173
Alohci Avatar answered Oct 13 '22 23:10

Alohci