sonny8441 / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

add serialVersionUID to base classes? #265

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Rumor has it that serialVersionUID is supposed to be not just on a class 
that gets serialized, but on every parent class from there on up (even 
abstract ones), in order to get the full benefit.  Or, could it be that only 
parent classes that have state are of any concern?  I don't know, but I 
guess we should get this right.

Original issue reported on code.google.com by kevin...@gmail.com on 16 Oct 2009 at 11:47

GoogleCodeExporter commented 9 years ago
apparently this is only necessary when the base class itself implements 
Serializable.  
I'm confused (as I always am when it comes to serialization.)

Original comment by kevin...@gmail.com on 21 Oct 2009 at 12:13

GoogleCodeExporter commented 9 years ago
Quote from Javadoc (java.io.Serializable):

"However, it is strongly recommended that all serializable classes explicitly 
declare
serialVersionUID values".

This means all classes that implement Serializable (by direct or inherited
implementation).

Original comment by ogregoire on 21 Oct 2009 at 8:18

GoogleCodeExporter commented 9 years ago
That javadoc excerpt is too vague I'm afraid. This is a subtle issue.

right now, the abstract classes we have that implement Ser. but have no svuid 
are:

AbstractMapBasedMultiset
AbstractMultimap
ImmutableCollection
ImmutableMap

if any of these are only implementing it for the convenience of their 
subclasses not 
having to say it explicitly, we should fix that, but some are necessary, and I 
guess 
in those cases we just add this dang thing and this is fixed.

Original comment by kevin...@gmail.com on 5 Nov 2009 at 1:21

GoogleCodeExporter commented 9 years ago
All 4 Abstract*Multimap classes should have a serialVersionUID.

However, I don't think it's necessary for the Immutable* classes, since they 
have a
separate serialized form.

Original comment by jared.l....@gmail.com on 6 Nov 2009 at 7:36

GoogleCodeExporter commented 9 years ago
that's good to hear.  I think that the other Abstract*Multimap classes must 
already 
have it, that's why they didn't end up in my list.

Original comment by kevin...@gmail.com on 6 Nov 2009 at 8:13

GoogleCodeExporter commented 9 years ago
The other Abstract*Multimap classes don't say "implements Serializable" since 
their
superclass does. That's probably why you omitted them.

Original comment by jared.l....@gmail.com on 6 Nov 2009 at 9:11

GoogleCodeExporter commented 9 years ago

Original comment by kevin...@gmail.com on 9 Nov 2009 at 6:35

GoogleCodeExporter commented 9 years ago
All the classes the need a serialVersionUID now have one. I just fixed
Abstract*Multimap and AbstractMapBasedMultiset.

Original comment by jared.l....@gmail.com on 9 Nov 2009 at 11:30