I have an enum JJJ that has 3 values: A, B, and C. In previous versions of my program it had one additional value: D. I'd like to be able to read in the serialized objects created by previous versions of the program, but an exception is thrown when it encounters a JJJ type variable with value 'D' in the serialized object. Optimally, I'd like to be able to intercept the deserialization process and tell it to just map D's to C's when it encounters them.
According to http://docs.oracle.com/javase/6/docs/platform/serialization/spec/serial-arch.html (Serialization of Enum Constants), it doesn't sound like there is a simple way to do this... I know that one approach would be to override readObject on the classes that contain member variables of type JJJ, but this would be difficult and painful due to the size and scope of the program (dozens of serializable classes have member vars of type JJJ and overriding readObject to handle the JJJ field means I'd have to manually handle all of the other fields as well).
I've also attempted to solve this by rolling my own subclass of ObjectInputStream, but unfortunately the enum deserialization bits I really need to get at and override to solve this are all private or package private...
Any suggestions?