This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes I/O and Streams and the fly likes can't deserialize in Java 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "can Watch "can New topic
Author

can't deserialize in Java 6

Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
On one computer (with Java 6) I was working on a file, then I saved it (serialized it) and then transferred it to another computer with Java 1.4. I had no problem opening the file and serializing it again in Java 1.4. But then I transferred it to the Java 6 computer and tried to open it, I got this message:
java.io.StreamCorruptedException: invalid handle value: 005E39C7
at java.io.ObjectInputStream.readHandle(Unknown Source)
and some other Exception detail lines which include
at java.util.TreeMap.buildFromSorted(Unknown Source)

The object I want to read is of a class which is compiled by code which I wrote. That class contains TreeMap objects which are to be serialized as part of the object. What I think is that somehow TreeMap in java 1.4 differs from TreeMap in java 6.
I would expect java 1.4 not to be able to open an object serialized by java 6, but I did not expect that java 6 could not open an object serialized by java 1.4.

I don't know if this makes any difference, but the .class files were created this way: I have some text files *.java and I compiled the files twice, once on each of the two computers.

Help!
Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
I think I know what the problem was. I went back to the computer with java 1.4 on it and tried opening both the file saved on that computer, and the file which was copied over to the flash memory. The file saved on the computer opened fine, but the file on the flash memory gave the same Exception message. So I think the file became corrupted when transferred to the flash memory. So it's not a problem with java.
Never mind!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41571
    
  54
I think it's more likely to be a version problem - serialization using object streams generally doesn't work if two different JRE versions are involved at the two ends.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can't deserialize in Java 6