You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Mikhail Loenko <ml...@gmail.com> on 2006/01/19 09:59:46 UTC

[classlib] serialVersionUIDs for Serializable classes

Hello,

Do we need to have serialVersionUIDs for all Serializable classes even if those
fields are missing in API Spec or we might omit them?

According to Java Object Serialization Specification, 4.6
http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/class.html#4100

"It is strongly recommended that all serializable classes explicitly declare
serialVersionUID values, since the default serialVersionUID
computation is highly
sensitive to class details that may vary depending on compiler implementations,
and can thus result in unexpected serialVersionUID conflicts during
deserialization,
causing deserialization to fail"

I suggest to have these fields for all serialized classes, unless
there is a particular
reason for those classes not to have serialVersionUID

(And I'm not saying that we need them instead of serialization tests :)

Opinions?

Thanks,
Mikhail Loenko
Intel Middleware Products Division

Re: [classlib] serialVersionUIDs for Serializable classes

Posted by Tim Ellison <t....@gmail.com>.
Mikhail Loenko wrote:
> Hello,
> 
> Do we need to have serialVersionUIDs for all Serializable classes even if those
> fields are missing in API Spec or we might omit them?
> 
> According to Java Object Serialization Specification, 4.6
> http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/class.html#4100
> 
> "It is strongly recommended that all serializable classes explicitly declare
> serialVersionUID values, since the default serialVersionUID
> computation is highly
> sensitive to class details that may vary depending on compiler implementations,
> and can thus result in unexpected serialVersionUID conflicts during
> deserialization,
> causing deserialization to fail"
> 
> I suggest to have these fields for all serialized classes, unless
> there is a particular
> reason for those classes not to have serialVersionUID
> 
> (And I'm not saying that we need them instead of serialization tests :)
> 
> Opinions?

I agree.
(I suppose I should get used to just saying "+1", to fit in round here).

Regards,
Tim

> Thanks,
> Mikhail Loenko
> Intel Middleware Products Division
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.