Re: Cleaning up bad stream data
Sunday, August 18, 2002 07:35 PM
I believe your two step solution is the only way. This exact problem you are describing, by the way, is why Serialization is not suggested as a mechanism for long-term storage. It's really meant for temporary transport ( like between JVMs in a distributed application ).
You might, however, be able to do some craziness with ClassLoaders to make the two step process appear to happen in one step to the users. Use a special ClassLoader to load the old class, deserialize the object, and then convert it to kind of class-less form ( a string, an xml document, whatever ), then use this form, as you suggested, to create an instance of the new class ( using the System classloader ).
Hope this helps.