Re: FindBugs issue with transient
Paul Tomblin wrote:
In a previous article, "Jeff Higgins" <oohiggins@yahoo.com> said:
Paul Tomblin wrote:
I just insalled the FindBugs plugin in Eclipse, and while it whines about
a bunch of stuff that I don't care about, it's found a few real ones. But
there is a warning that I don't understand at all. A transient variable
in a serializable class is marked:
H B Se: The field <variable name> is transient but isn't set by
deserialization.
What does that mean?
<http://en.wikibooks.org/wiki/Java_Programming/Keywords/transient>
Excuse me, I didn't mean that I didn't know why I put "transient" in my
own program, I meant to ask why FindBugs thinks it is a problem that it
isn't set by deserialization. I initialize the variable in the default
ctor. Would it be happier if I initialized it in the declaration line?
Deserialization skips the default ctor, so you have a bug. It also
skips the default initializers. If you need it set to a default value,
you must set it after deserialization.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>