how does serializable work in java?
Posted
by
Karl Trumstedt
on Stack Overflow
See other posts from Stack Overflow
or by Karl Trumstedt
Published on 2011-01-09T20:45:57Z
Indexed on
2011/01/09
20:53 UTC
Read the original article
Hit count: 203
java
|serialization
If I have an instance of a class that I store in a session I need to make it serializable. This class has a static variable, will this be serialized in every instance stored?
The static variable is a reference to a cache containing a lot of data in the background. Will all of this data be serialized? If so, it seems preferable to make this variable transient and re-fetch the cache instance each time the instance is restored. Maybe not store the cache instance at all in the class.
Will the constructor execute when a class is restored from a serialized state? if not is there any other method I can use to re-instate a transient variable?
© Stack Overflow or respective owner