Lets say that I have a program that for some reason need to handle old versions of serialized objects.
Eg: when deserializing, one of these versions may be encountered.
class Pet {
private static final long serialVersionUID = 1L;
int paws;
}
class Pet {
private static final long serialVersionUID = 2L;
long paws; // handle marsian centipedes
boolean sharpTeeth;
}
Lets assume that it's (logically) possible to convert an old object to a new object using some clever strategy to set nonexistant fields etc etc, but:
How do I arrange my source code? I would probably need both versions in the same source tree when writing a converter, but how do I handle that in , say, eclipse.
Should I do deserialization in one class loader, and if that fails try using another class loader that uses an older version (and so on), or are there better ways?
What's the best strategy?