jiweigang1 / google-collections

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

Serialization Refactoring Support #243

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It's often necessary (or useful) to refactor code that's been serialized. 
It's a PITA to require old classes to sit around just for the sake of
deserializing.  One approach to this is to avoid ever serializing classes
and instead only serialize memento-style objects -- but that can become
unwieldy very often.  For situations when mementos are impossible, we've
been using an approach that locates the newer class on-the-fly, not
requiring the old class to even exist anymore.  We've been using this
approach for the past 5-6 years or so, and it works wonders.

See:
https://www.limewire.org/fisheye/browse/~raw,r=1.17/limecvs/components/common/sr
c/main/java/org/limewire/util/ConverterObjectInputStream.java

The basic idea is you tell it "this is the package or name of my old
class", and "this is the package or name of my new class".  If you
construct your ObjectInputStream as a ConverterObjectInputStream instead,
it will transparently return the new classes, without even requiring that
the old classes exist on the classpath (or anywhere, for that matter).

We initially developed this back when we migrated off of
com.sun.java.util.collections and began using java.util... and have made
great use of it to allow us to refactor with ease.

Feel free to take the code & modify as necessary for inclusion (such as
removing our built-in conversions referencing the limewire code).

Original issue reported on code.google.com by sberlin on 18 Sep 2009 at 2:09

GoogleCodeExporter commented 9 years ago
Thanks for the suggestion. 

For now, we'll focus on making sure our current serialized forms are correct and
adding tests to verify that. We don't want to delay the 1.0 release by adding 
any
additional serialization functionality.

Original comment by jared.l....@gmail.com on 18 Sep 2009 at 9:19

GoogleCodeExporter commented 9 years ago

Original comment by kevin...@gmail.com on 21 Sep 2009 at 5:50

GoogleCodeExporter commented 9 years ago
This issue has been moved to the Guava project (keeping the same id number). 
Simply replace 'google-collections' with 'guava-libraries' in your address 
bar and it should take you there.

Original comment by kevinb@google.com on 5 Jan 2010 at 11:09