> But don't forget that you are now responsible for maintaining the UID. If you
> change the class in any meaningful way (such that the data which is serialized
> will be different) then you should update the serialVersionUID. The prevents a
> class with one UID attempting to de-serialize objects with a different UID, and
> hence incompatible contents.
>> But don't forget that you are now responsible for maintaining the UID. If you
>> change the class in any meaningful way (such that the data which is serialized
[quoted text clipped - 3 lines]
>
> No no no. That will break your downward compatilibity.
Yes, yes, yes. If you break the backwards compatibility then you must change the
UID, or face the consequences.
> Serialization
> already supports versioning to a great extent. As long as you stay
[quoted text clipped - 7 lines]
> serialization-compatible with the old one, and there is an awful lot
> more you can do within these mechanisms.
What I said was that if you change the contents of the serialized object then
you must manually alter the UID. That remains valid no matter how many rules
and tools you use to try to circumvent it.
> If you *want* to break backwards compatibility, and lose contact forever
> with any persistent serializations you may have done, then change the
> serialVersionUID. Not otherwise.
Like I said...

Signature
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
Esmond Pitt - 20 Jun 2007 02:06 GMT
> Yes, yes, yes. If you break the backwards compatibility then you must change the
> UID, or face the consequences.
But if you don't, don't. And please read the Serialization/Versioning
spec carefully before you decide that you have broken backwards
compatibility. Better still, design so that you don't ever do this.
> What I said was that if you change the contents of the serialized object then
> you must manually alter the UID.
And this is still not correct. See the Serialization/Versioning spec, or
my hasty summary of it. You can change a serializable class in lots of
ways without breaking serialization-compatibility. In a practical
production system it behoves you to keep compatibility in mind at all
times, and to have an *accurate* view of what that actually means in
practice. This means reading the Serialization specification, the
section on Versioning, no two ways about it.