Java Reference
In-Depth Information
The main lesson of this puzzle is that
a singleton class that implements
Serializable
must have
a
readResolve
method that returns its sole instance.
A secondary lesson is that it is possible to
implement
Serializable
unintentionally, by extending a class that implements
Serializable
or
by implementing an interface that extends
Serializable
. A lesson for platform designers is that
hidden constructors, such as the one provided by serialization, can harm the reader's intuition about
program behavior.
< Day Day Up >
Search WWH ::
Custom Search