Java serialization: readObject() vs. readResolve() -
The book effective Java and other sources provide a very good description on how and how to use it Does readObject () method work when serializable Java classes. On the other hand, the radolive () method is a small part of a mystery. Originally in all the documents I have mentioned either of the two or have only mentioned both personally.
Questions that remain unanswered:
- What is the difference between the two methods?
- Which method should be implemented?
- In particular, how should resolve () be used in return?
I hope there is some light on this matter.
is used for readResolve the object from the stream Read Change. I have seen only one use for it; When an object is read, replace it with the Singleton Instance. This ensures that no one can make another example for serializing and declining singletones.
Comments
Post a Comment