I have several objects that I serialized and now need to edit, is there an approach to this without losing all the data I had stored in the files using the serialization.
EDIT [from comment] I dont need to edit the objects themselves I need to edit the Objects code, such as adding methods to it.
-
You'll have a hard time editing serialized streams, if that's what you're talking about. If it isn't, your question remains unclear.user207421– user2074212014年04月01日 23:06:08 +00:00Commented Apr 1, 2014 at 23:06
2 Answers 2
I dont need to edit the objects themselves I need to edit the Objects code, such as adding methods to it
Aha. An actual problem. OK.
Run the
serialverutility on the .class files as they are now.Add the declarations output by
serialverto the source code of each class respectively.Have a really good look at the Versioning chapter of the Object Serialization Specification to see what you can and cannot do while retaining compatibility with the existing stream.
2 Comments
Load the objects in memory, edit the objects themselves, then save them back.
This is the safest way of doing it (if not the only way).