Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Serialization  RSS feed

 
hua ser
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to make the serialized object have the compatibility between different version of JRE.
The serialized object in JRE1.3 couldn't be read in JRE1.4.I don't know how to do.
It throws the exception like the following:
IOException: javax.swing.text.AbstractDocument; Local class not compatible:
stream classdesc serialVersionUID=-116069779446114664
local class serialVersionUID=7931792678889779483
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you're screwed as far as I know just like I am. If you read the java docs on AbstractDocument (which you are using in some way) it says:
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.

I did the same thing with an AbstractListModel. I didn't use it directly, but one of the Java objects i was saving used it. Now I am having to write conversion code to change the savefiles to save the stuff in the ListModel as an array. Then I have to reconstruct the ListModel when I am reading in the save file.
Sorry, but you'll have to stick with 1.3 or convert your save files(using 1.3) to something that doesn't use the AbstractDocument. Make sure none of the other objects you save are based on incompatible Objects.
 
hua ser
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think you for your advice,but doing it like you said seems more difficult,is there exist more convinent method to resolve the problem?
I also paid attention to the "Warning....",
but I also know there is a version control with object serialization,how it's to work?
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid that there is no alternative as far as I know. If you have files that have been saved using the 1.3 code and you need the data they contain, you will have to either continue using 1.3 to open them, or (using 1.3) save them to a different format that doesn't depend on the objects that have changed for version 1.4.
Now there is a way to make your own objects carry forward easily by manually setting the serialVersionUID for your object like this

I explained using it a bit in the third part of the post
HERE. If you have any more questions, let me know.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!