When you want to do only a part of the serialisation/deserialisation yourself you must invoke the defaultReadObject() & defaultWriteObject().
What defaultReadObject() & defaultWriteObject() does?
kunal dabir
Greenhorn
Joined: Sep 08, 2008
Posts: 15
posted
0
When you want to do only a part of the serialisation/deserialisation yourself you must invoke the defaultReadObject() & defaultWriteObject().
What defaultReadObject() & defaultWriteObject() does?
1. It's not compulsory to invoke defaultReadObject() & defaultWriteObject(). 2. both methods are called to carry out the serialization/deserialization process which would occur if you had not implemented read/writeObject.
Also remember, the order in which you call defaultXXXObject() inside XXXObject() is also very important.
Where I have seen that discussed is in the case where you want to write out field values that are non-serializable so you override the writeObject() and readObject() methods. Within your overridden method you still have to account for serializing the serializable part of the object/object graph, so you should imbed a defaultWriteObject() / defaultReadObject() to do the normal part of serialization/deserialization. At least that is what I thought it was.
------------------------
Bob
SCJP - 86% - June 11, 2009