0

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.

dsolimano
9,0463 gold badges52 silver badges67 bronze badges
asked Apr 1, 2014 at 22:56
1
  • 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. Commented Apr 1, 2014 at 23:06

2 Answers 2

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.

  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.

answered Apr 1, 2014 at 23:24
Sign up to request clarification or add additional context in comments.

2 Comments

@peter.petrov Well it took half a dozen questions to elicit it. It's like pulling teeth.
Sorry I should have made it more clear thanks for sticking with me. The link you sent me in Number 3, doesn't say anything about adding or removing methods or I missed it. So can I add methods to the class that is serialized?
1

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

answered Apr 1, 2014 at 23:09

9 Comments

Okay so in the Compiler I should run it in debug mode then edit and resave the objects?
Doesn't need to be in debug mode. Just load your objects from disk, change them (with whatever values you want to set into them), save them back to disk.
@BrentColeman In the compiler? Do you mean the IDE? What does the IDE have to do with it? Where is it mentioned in your question? What is your question?
@EJP I assumed that's what OP meant.
@BrentColeman Maybe you should rephrase in details your question and explain exactly what situation you have and what you want to achieve.
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.