• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in deserialization with different versions of JDK  RSS feed

 
Premier Indore
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have problem related to serialization, pls suggest the most appropriate solution, the problem is that I have a class AAAA.java which extends AbstractListModel.java class of JDK, and it is serializable. When i saw the serialVersionUID of AbstractListModel.java using the java tool serialver in jdk 1.3.1 from the command line it gives 2622425607724314306 (Unique ID of class) but when i saw it in JDK 1.4.1 then it given -3285184064379168730. As the UID is changed from JDK1.3.1 to 1.4.1, Now the problem is that i serialized a file which uses AAAA.java using the 1.3.1 and now i want to open that file in my project using 1.4.1 it gives exception.
java.io.InvalidClassException: javax.swing.AbstractListModel; local class incompatible: stream classdesc serialVersionUID = 2622425607724314306, local class serialVersionUID = -3285184064379168730
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:459)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
Can u suggest me appropriate solution as this file must be desirialized (Compatibility issue) as it is generated from project.
U may also try using this command in jdk 1.3.1 & 1.4.1
on command prompt
serialver javax.swing.AbstractListModel.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the Javadoc pages for virtually all of the Swing classes, they include this warning near the top of the page (this one is from the AbstractListModel page

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. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

Whoever designed this application apparently ignored this warning. There isn't much you can do here, unfortunately, short of developing your own encoding scheme which works with JDK 1.3 and 1.4.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!