Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > FindBugs issue with transient

Reply
Thread Tools

FindBugs issue with transient

 
 
Paul Tomblin
Guest
Posts: n/a
 
      07-23-2008
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?

--
Paul Tomblin <(E-Mail Removed)> http://blog.xcski.com/
Never underestimate the bandwidth of a station wagon full of
tapes hurtling down the highway.
-- Andrew Tannenbaum possibly quoting Warren Jackson
 
Reply With Quote
 
 
 
 
Jeff Higgins
Guest
Posts: n/a
 
      07-23-2008

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>


 
Reply With Quote
 
 
 
 
Jeff Higgins
Guest
Posts: n/a
 
      07-23-2008

Jeff Higgins wrote:
>
> 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>
>


<http://en.wikipedia.org/wiki/Serialization#Java>


 
Reply With Quote
 
Paul Tomblin
Guest
Posts: n/a
 
      07-23-2008
In a previous article, "Jeff Higgins" <(E-Mail Removed)> 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?


--
Paul Tomblin <(E-Mail Removed)> http://blog.xcski.com/
Can't get out of 'vi'? Common problem. Don't worry, I'm here to help. Just
log in as root and type "init 0". It works for pretty much any problem you
might have with Linux. No, no, no. Thank /you/. -- Mikey Raeder
 
Reply With Quote
 
Jeff Higgins
Guest
Posts: n/a
 
      07-23-2008

Jeff Higgins wrote:
>
> Jeff Higgins wrote:
>>
>> 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>
>>

>
> <http://en.wikipedia.org/wiki/Serialization#Java>
>


<http://findbugs.sourceforge.net/bugDescriptions.html>


 
Reply With Quote
 
Jeff Higgins
Guest
Posts: n/a
 
      07-23-2008

Paul Tomblin wrote:
> In a previous article, "Jeff Higgins" <(E-Mail Removed)> 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?
>
>

RTFM


 
Reply With Quote
 
Paul Tomblin
Guest
Posts: n/a
 
      07-23-2008
In a previous article, "Jeff Higgins" <(E-Mail Removed)> said:
><http://findbugs.sourceforge.net/bugDescriptions.html>


Ah, that's very useful. Thanks.

Turns out it's a crap warning - the default value is appropriate when it's
been deserialized, and they're just warning me it might not be.


--
Paul Tomblin <(E-Mail Removed)> http://blog.xcski.com/
"Our documented process says that I must now laugh in your face and double our
price." - Dilbert's boss does ISO-9000
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      07-25-2008
Paul Tomblin wrote:
> In a previous article, "Jeff Higgins" <(E-Mail Removed)> 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/>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
varying eclipse and ant output in findbugs crazzybugger Java 0 12-21-2007 03:36 PM
Remove a Category from findbugs? comp.lang.java.programmer Java 2 02-23-2007 03:50 PM
How to use Findbugs 1.1 (as compared to say .95) opalpa@gmail.com opalinski from opalpaweb Java 2 10-02-2006 04:21 PM
How can I view the findbugs report in an alpha order hongjie.yang@gmail.com Java 0 05-16-2006 03:06 AM
findbugs for C/C++? yusufm@gmail.com C++ 5 03-05-2006 02:31 PM



Advertisments