简体   繁体   中英

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM