ACMNexus / google-collections

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

Factory methods that require Suppliers should document Serializableness of the Collection depends on the Supplier being serializable #84

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Multimaps.forMap(Map) notes "The returned multimap will be serializable if the 
specified map is 
serializable."

Similarly the factory methods that accept a Supplier generally return an 
anonymous subclass of a 
serializable type that retains a final reference to the supplier. These will 
fail serialization if the 
supplier is not serializable.

Another related point is that these Supplier utilising anonymous types will 
have a synthetic 
signature. This is a pita for library changes as the created name is difficult 
to control and 
reconciling the serialized signature between library versions (even between the 
same source 
compiled by differen t compilers) can become virtually impossible. For API 
migration sake it might 
be better to not use template methods and use Suppliers directly in the base 
class.

Original issue reported on code.google.com by jed.wesl...@gmail.com on 15 Jun 2008 at 4:46

GoogleCodeExporter commented 8 years ago
Thanks for pointing that out. I'll update the docs. Also, I'll modify all
serializable inner classes so they're no longer anonymous.

We could get rid of the suppliers completely and make the Standard*Multimap 
classes
public. I'm not sure whether it's better to have fewer public classes, at the 
cost of
dealing with suppliers.

Original comment by jared.l....@gmail.com on 16 Jun 2008 at 4:47

GoogleCodeExporter commented 8 years ago

Original comment by jared.l....@gmail.com on 16 Jun 2008 at 4:48

GoogleCodeExporter commented 8 years ago
I must admit that personally I prefer the Supplier composition style rather 
than inheritance for the sake of a 
template method.

Original comment by jed.wesl...@gmail.com on 17 Jun 2008 at 9:19

GoogleCodeExporter commented 8 years ago
I've fixed the Javadoc and modified the code to use named inner classes. The 
revised
code will be in our next release. 

Original comment by jared.l....@gmail.com on 16 Jul 2008 at 10:48