ItsRainingHP
ItsRainingHP

Reputation: 149

Serialization and Deserialization

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.

Upvotes: 0

Views: 72

Answers (2)

user207421
user207421

Reputation: 311031

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.

  1. Run the serialver utility on the .class files as they are now.

  2. Add the declarations output by serialver to the source code of each class respectively.

  3. 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.

Upvotes: 2

peter.petrov
peter.petrov

Reputation: 39477

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).

Upvotes: 1

Related Questions