aspose file tools*
The moose likes I/O and Streams and the fly likes Deserialize Using value of 1L Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Deserialize Using value of 1L" Watch "Deserialize Using value of 1L" New topic
Author

Deserialize Using value of 1L

Santosh Kumar Nayak
Ranch Hand

Joined: Aug 02, 2011
Posts: 82
Hi

For a Serialized Object we use 1L to Deserialize the Object.

what will happen if we use the same generated value of 1L in another JVM.

We move the serialized object to another JVM and try De-serialization on that JVM ?


Heena Agarwal
Ranch Hand

Joined: Dec 25, 2013
Posts: 254
    
    4
1L? What is that?

Are you referring to the serialVersionUID?
Santosh Kumar Nayak
Ranch Hand

Joined: Aug 02, 2011
Posts: 82
Yes I am referring to the value of SerialVersionUID.
Heena Agarwal
Ranch Hand

Joined: Dec 25, 2013
Posts: 254
    
    4
Sorry, don't know..

Pass..
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18136
    
  39

Santosh Kumar Nayak wrote:Yes I am referring to the value of SerialVersionUID.


When you set a serial version UID, you are taking responsibility for the serialization compatibility. If you have two versions of the same class, that is not compatible with each other -- setting them to the same serial version UID is not a good idea.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18152
    
    8

And there's nothing magic about the value 1 for the serial version UID either. You could use 8055 if you liked, and then if you changed the class in a compatible way and continued to use 8055 then things would work fine. So your idea that "we use 1L" is likely based on a small number of examples that you have seen. It isn't a rule or even a convention.
Santosh Kumar Nayak
Ranch Hand

Joined: Aug 02, 2011
Posts: 82
When we Deserialzie the Object in another JVM then will we face any issue. As I have taken the value of 1L is from the old JVM

Note: there has been no changes to the original class
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18152
    
    8

It isn't the JVM which deserializes the object which will be the cause of any problems. The problems can arise if the application doing the deserializing has a different version of the class which was used when serializing.
Heena Agarwal
Ranch Hand

Joined: Dec 25, 2013
Posts: 254
    
    4
Thanks Paul, Henry.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Deserialize Using value of 1L
 
Similar Threads
Serialization
serialization and VM
object serilization and deserialization..
serialization and transient
what is the use of Serialization in java?