Java / Java Serialization
Difference between readResolve and readObject methods in Java serialization.
For Serializable and Externalizable classes, the readResolve method allows a class to replace/resolve the object read from the stream before it is returned to the caller. By implementing the readResolve method, a class can directly control the types and instances of its own instances being deserialized. This method is called when ObjectInputStream has read an object from the stream and is preparing to return it to the caller.
For serializable objects, the readObject method allows a class to control the deserialization of its own fields and held responsible for restoring the state of the class.
More Related questions...