Advice needed on using ObjectInputStream/OutputStream for (de)serialization processes, how to keep older version readable?

In my software, I have a large class representing a document, which is saved to file using ObjectOutputStream and later read out by ObjectInputStream.  While everything's very convenient, problem arises every time I tried to modify anything in that class, or any class that the class references (of course those objects are saved along with the main document object) --- the new class won't be able to read old document any more and throws an exception about class ID not matching.

While this is expected behavior, it gets really annoying because if I do any upgrades, I would have to provide a way to migrate old files over.  Of course one way is to keep two sets of classes, the old one and convert to new one.  But once there're several versions, this is not going to be workable.

So my question is:

What would be the best way to solve this upgrade problem in my situation?  Namely, Is there anyway to easily read old objects without exception into new objects?  I never used resolveObject() but would it help? how?  Or should I abandon ObjectOutputStream etc. altogether and write my own class?  That would be a big hassle, however, and it has to be the very last resort.

Thanks in advance.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zzynxSoftware engineerCommented:
zzynxSoftware engineerCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Or just use the XMLEncoder in java.beans.XMLEncoder
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

inq123Author Commented:
zzynx, thanks!  Although I havent tried it out but it should be the solution that I need.  Simple and effective.

TimYates, thanks for your answer.  It's interesting but it would involve more work (converting to public members and providing get/setters for all members) and produce a larger file I believe, so I probably won't use it.
Fair enough :-)

Glad to give you a different direction to investigate anyways ;-)

Good luck with it!!

zzynxSoftware engineerCommented:
Thanks for accepting
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.