Main Topics
Browse All TopicsIn 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.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
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.
Business Accounts
Answer for Membership
by: zzynxPosted on 2004-11-22 at 07:57:44ID: 12645436
Versioning of Serializable Objects: http://java.sun.com/j2se/1 .3/docs/gu ide/serial ization/sp ec/ version .doc.html