You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Sébastien Brisard <se...@m4x.org> on 2011/08/06 10:31:56 UTC

[math] serialVersionUID

Hi,
I've just realized that many classes I've submitted do not define
serialVersionUID, which raises a warning. I have to say that it's
something I've never done myself, but I'd like to avoid the committers
the burden of inserting this. What's the rule for chosing this number?
(sorry for the silly question).
Best regards,
Sébastien

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


Re: [math] serialVersionUID

Posted by Phil Steitz <ph...@gmail.com>.
On 8/6/11 9:38 AM, Stefan Bodewig wrote:
> On 2011-08-06, Gilles Sadowski wrote:
>
>>> I've just realized that many classes I've submitted do not define
>>> serialVersionUID, which raises a warning.
>> Who reaises a warning?
> javac (when run with -Xlint:serial or -Xlint or something similar).

And Eclipse, unless you suppress it.
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


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


Re: [math] serialVersionUID

Posted by Stefan Bodewig <bo...@apache.org>.
On 2011-08-06, Gilles Sadowski wrote:

>> I've just realized that many classes I've submitted do not define
>> serialVersionUID, which raises a warning.

> Who reaises a warning?

javac (when run with -Xlint:serial or -Xlint or something similar).

Stefan

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


Re: [math] serialVersionUID

Posted by Gilles Sadowski <gi...@harfang.homelinux.org>.
> I've just realized that many classes I've submitted do not define
> serialVersionUID, which raises a warning.

Who reaises a warning?

> I have to say that it's
> something I've never done myself, but I'd like to avoid the committers
> the burden of inserting this.

IMHO, a class should be "Serializable" only if there is reason for it.

> What's the rule for chosing this number?

Good question. I'm also used to "1L" but it appears that Luc has a more
clever algorithm ;-).

> (sorry for the silly question).

Let's see if the answer was obvious...


Regards,
Gilles

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


Re: [math] serialVersionUID

Posted by Stefan Bodewig <bo...@apache.org>.
On 2011-08-06, Sébastien Brisard wrote:

> I've just realized that many classes I've submitted do not define
> serialVersionUID, which raises a warning. I have to say that it's
> something I've never done myself, but I'd like to avoid the committers
> the burden of inserting this. What's the rule for chosing this number?

Obviously different people have different rules. 8-)

I tend to run the JDK's servialver tool on the class before adding the
serialVersionUID and use that value, it is the value the class would
have without the long attribute in the first place.

Stefan

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


Re: [math] serialVersionUID

Posted by Dave Brosius <db...@apache.org>.
On 08/07/2011 12:17 PM, Luc Maisonobe wrote:
>
> I use eclipse for this.
>
> I like Jörg suggestion too but have one question: is there a problem 
> if two different classes have the same id ? They will differ by fully 
> qualified class name, of course, but is it sufficient ?

nothing wrong with two classes having the same serialVersionUID.

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


Re: [math] serialVersionUID

Posted by Luc Maisonobe <Lu...@free.fr>.
Le 06/08/2011 19:00, Phil Steitz a écrit :
> On 8/6/11 5:21 AM, Jörg Schaible wrote:
>> Sébastien Brisard wrote:
>>
>>> Hi,
>>> I've just realized that many classes I've submitted do not define
>>> serialVersionUID, which raises a warning. I have to say that it's
>>> something I've never done myself, but I'd like to avoid the committers
>>> the burden of inserting this. What's the rule for chosing this number?
>>> (sorry for the silly question).
>> I started to use YYYYMMDD e.g. to day I would take 20110806L. It gives me a
>> hint when the number was chosen resp. binary compatibility was last broken.
>
> Sounds reasonable.  Most of the earlier classes in [math] use the
> ids generated by the JDK utility serialver.   I think Eclipse will
> do that automatically, which is fine by me.  I am also OK with

I use eclipse for this.

I like Jörg suggestion too but have one question: is there a problem if 
two different classes have the same id ? They will differ by fully 
qualified class name, of course, but is it sufficient ?


> Jorg's suggestion or James' (though in the latter case, I would
> favor 42l - even though I am 42R ;).   The important thing is to put
> something there and change it when a serialization incompatible
> change is made to the class.

+1, despite I am lazy on this and change the number sometimes even if 
the changes are compatible. I also never tried to set up deserialization 
that would be aware of both past and current versions, as it would 
really be a nightmare to maintain

Luc

>
> Phil
>>
>> - Jörg
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


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


Re: [math] serialVersionUID

Posted by Phil Steitz <ph...@gmail.com>.
On 8/6/11 5:21 AM, Jörg Schaible wrote:
> Sébastien Brisard wrote:
>
>> Hi,
>> I've just realized that many classes I've submitted do not define
>> serialVersionUID, which raises a warning. I have to say that it's
>> something I've never done myself, but I'd like to avoid the committers
>> the burden of inserting this. What's the rule for chosing this number?
>> (sorry for the silly question).
> I started to use YYYYMMDD e.g. to day I would take 20110806L. It gives me a 
> hint when the number was chosen resp. binary compatibility was last broken.

Sounds reasonable.  Most of the earlier classes in [math] use the
ids generated by the JDK utility serialver.   I think Eclipse will
do that automatically, which is fine by me.  I am also OK with
Jorg's suggestion or James' (though in the latter case, I would
favor 42l - even though I am 42R ;).   The important thing is to put
something there and change it when a serialization incompatible
change is made to the class.

Phil
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


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


Re: [math] serialVersionUID

Posted by Jörg Schaible <jo...@gmx.de>.
Sébastien Brisard wrote:

> Hi,
> I've just realized that many classes I've submitted do not define
> serialVersionUID, which raises a warning. I have to say that it's
> something I've never done myself, but I'd like to avoid the committers
> the burden of inserting this. What's the rule for chosing this number?
> (sorry for the silly question).

I started to use YYYYMMDD e.g. to day I would take 20110806L. It gives me a 
hint when the number was chosen resp. binary compatibility was last broken.

- Jörg


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


Re: [math] serialVersionUID

Posted by James Carman <ja...@carmanconsulting.com>.
Use 1L :)


2011/8/6 Sébastien Brisard <se...@m4x.org>:
> Hi,
> I've just realized that many classes I've submitted do not define
> serialVersionUID, which raises a warning. I have to say that it's
> something I've never done myself, but I'd like to avoid the committers
> the burden of inserting this. What's the rule for chosing this number?
> (sorry for the silly question).
> Best regards,
> Sébastien
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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