You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Ted Husted <hu...@apache.org> on 2007/09/06 15:42:28 UTC

Should we add serialVersionUID fields for example applications?

So, for complicated reasons, I'm trying to use Eclipse more these days.

Something it likes to do is nag that "The serializable class
$classname does not declare a static final serialVersionUID field of
type long".

Since the Actions are serializable, we get this alot :)

A seemingly good explanation of the message is here:

 * http://forum.java.sun.com/thread.jspa?threadID=581654&messageID=3501336

Do we want to go ahead and add the field and silence the nag? Or just
turn it off in our Eclipse IDEs? Or add the "@SupressWarnings"
annotations? Otherwise, it's hard to tell if we've addressed any other
warnings.

If we were to add it and use the "quick fix", should we "add a default
serial ID" or  "add generated serial ID"?

-Ted.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Should we add serialVersionUID fields for example applications?

Posted by Paul Benedict <pb...@apache.org>.
Just add a value of 1.

On 9/6/07, James Mitchell <jm...@gmail.com> wrote:
>
> If you didn't know, you can turn off warnings for just that
> particular item under preferences.
>
>
> --
> James Mitchell
>
>
>
> On Sep 6, 2007, at 9:42 AM, Ted Husted wrote:
>
> > So, for complicated reasons, I'm trying to use Eclipse more these
> > days.
> >
> > Something it likes to do is nag that "The serializable class
> > $classname does not declare a static final serialVersionUID field of
> > type long".
> >
> > Since the Actions are serializable, we get this alot :)
> >
> > A seemingly good explanation of the message is here:
> >
> >  * http://forum.java.sun.com/thread.jspa?
> > threadID=581654&messageID=3501336
> >
> > Do we want to go ahead and add the field and silence the nag? Or just
> > turn it off in our Eclipse IDEs? Or add the "@SupressWarnings"
> > annotations? Otherwise, it's hard to tell if we've addressed any other
> > warnings.
> >
> > If we were to add it and use the "quick fix", should we "add a default
> > serial ID" or  "add generated serial ID"?
> >
> > -Ted.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: Should we add serialVersionUID fields for example applications?

Posted by Martin Cooper <ma...@apache.org>.
On 9/6/07, James Mitchell <jm...@gmail.com> wrote:
>
> If you didn't know, you can turn off warnings for just that
> particular item under preferences.


This would be my choice. Think about when instances of these classes are
ever going to be serialised anyway - pretty much only when a session is
being temporarily persisted during session migration in a distributed web
app. I can't imagine that we're going to end up with situations in which the
class definitions have changed in the middle of that.

--
Martin Cooper


--
> James Mitchell
>
>
>
> On Sep 6, 2007, at 9:42 AM, Ted Husted wrote:
>
> > So, for complicated reasons, I'm trying to use Eclipse more these
> > days.
> >
> > Something it likes to do is nag that "The serializable class
> > $classname does not declare a static final serialVersionUID field of
> > type long".
> >
> > Since the Actions are serializable, we get this alot :)
> >
> > A seemingly good explanation of the message is here:
> >
> >  * http://forum.java.sun.com/thread.jspa?
> > threadID=581654&messageID=3501336
> >
> > Do we want to go ahead and add the field and silence the nag? Or just
> > turn it off in our Eclipse IDEs? Or add the "@SupressWarnings"
> > annotations? Otherwise, it's hard to tell if we've addressed any other
> > warnings.
> >
> > If we were to add it and use the "quick fix", should we "add a default
> > serial ID" or  "add generated serial ID"?
> >
> > -Ted.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: Should we add serialVersionUID fields for example applications?

Posted by James Mitchell <jm...@gmail.com>.
If you didn't know, you can turn off warnings for just that  
particular item under preferences.


--
James Mitchell



On Sep 6, 2007, at 9:42 AM, Ted Husted wrote:

> So, for complicated reasons, I'm trying to use Eclipse more these  
> days.
>
> Something it likes to do is nag that "The serializable class
> $classname does not declare a static final serialVersionUID field of
> type long".
>
> Since the Actions are serializable, we get this alot :)
>
> A seemingly good explanation of the message is here:
>
>  * http://forum.java.sun.com/thread.jspa? 
> threadID=581654&messageID=3501336
>
> Do we want to go ahead and add the field and silence the nag? Or just
> turn it off in our Eclipse IDEs? Or add the "@SupressWarnings"
> annotations? Otherwise, it's hard to tell if we've addressed any other
> warnings.
>
> If we were to add it and use the "quick fix", should we "add a default
> serial ID" or  "add generated serial ID"?
>
> -Ted.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Should we add serialVersionUID fields for example applications?

Posted by Wes Wannemacher <we...@wantii.com>.
I've been getting this in Eclipse WTP forever. I ignored it for a while,
using quick fix is sort of bad because (if I understand correctly) the point
of a serialVersionUID is to create a number that maps to the class's
signature so that when de-serializing, a recipient will know if the
serialized version of the class is compatible with what it is looking for.
Why I think this is bad? Well, if I start working I'll see this warning
right away and "quick fix" it. Then, I'll start coding, which may or may not
include changing the classes methods. I have to remember at this point to
change the serialVersionUID. It's nice that Eclipse warns that no
serialVersionUID exists, but it's sort of counter-productive IMO.

-Wes

On 9/6/07, Ted Husted <hu...@apache.org> wrote:
>
> So, for complicated reasons, I'm trying to use Eclipse more these days.
>
> Something it likes to do is nag that "The serializable class
> $classname does not declare a static final serialVersionUID field of
> type long".
>
> Since the Actions are serializable, we get this alot :)
>
> A seemingly good explanation of the message is here:
>
> * http://forum.java.sun.com/thread.jspa?threadID=581654&messageID=3501336
>
> Do we want to go ahead and add the field and silence the nag? Or just
> turn it off in our Eclipse IDEs? Or add the "@SupressWarnings"
> annotations? Otherwise, it's hard to tell if we've addressed any other
> warnings.
>
> If we were to add it and use the "quick fix", should we "add a default
> serial ID" or  "add generated serial ID"?
>
> -Ted.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


-- 
Wesley Wannemacher
President, Head Engineer/Consultant
WanTii, Inc.
http://www.wantii.com

Re: Should we add serialVersionUID fields for example applications?

Posted by Rahul Akolkar <ra...@gmail.com>.
On 9/6/07, Antonio Petrelli <an...@gmail.com> wrote:
> 2007/9/6, Rahul Akolkar <ra...@gmail.com>:
> >
> > One of the reasons to generate is to
> > try to best guess the UID of a previous (serialization compatible)
> > version that didn't specify the UID.
>
>
>
> In fact, in JasperReports the UID contains the version number, something
> like:
> 20101 (for 2.1.1)
>
<snip/>

The downside to that (presuming they update the UIDs with every
release) is that it implies serialization is necessarily incompatible
across releases for all serializable classes included in both releases
(whereas in reality, some may remain compatible).

-Rahul


> Antonio
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Should we add serialVersionUID fields for example applications?

Posted by Antonio Petrelli <an...@gmail.com>.
2007/9/6, Rahul Akolkar <ra...@gmail.com>:
>
> One of the reasons to generate is to
> try to best guess the UID of a previous (serialization compatible)
> version that didn't specify the UID.



In fact, in JasperReports the UID contains the version number, something
like:
20101 (for 2.1.1)

Antonio

Re: Should we add serialVersionUID fields for example applications?

Posted by Rahul Akolkar <ra...@gmail.com>.
On 9/6/07, Ted Husted <hu...@apache.org> wrote:
> So, for complicated reasons, I'm trying to use Eclipse more these days.
>
<snip/>

;-)


> Something it likes to do is nag that "The serializable class
> $classname does not declare a static final serialVersionUID field of
> type long".
>
> Since the Actions are serializable, we get this alot :)
>
> A seemingly good explanation of the message is here:
>
>  * http://forum.java.sun.com/thread.jspa?threadID=581654&messageID=3501336
>
> Do we want to go ahead and add the field and silence the nag? Or just
> turn it off in our Eclipse IDEs? Or add the "@SupressWarnings"
> annotations? Otherwise, it's hard to tell if we've addressed any other
> warnings.
>
<snap/>

I'd say add
 * I'd imagine you'd want to promote this practice
 * Given these are example apps, it probably won't break anything in prod

However, as already pointed out, adding implies some commitment to
updating those when serialization incompatible changes are made
(again, for example apps, perhaps this is not much of a concern).


> If we were to add it and use the "quick fix", should we "add a default
> serial ID" or  "add generated serial ID"?
>
<snip/>

Default should be fine here IMO. One of the reasons to generate is to
try to best guess the UID of a previous (serialization compatible)
version that didn't specify the UID.

-Rahul


> -Ted.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org