• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deserialize Using value of 1L

 
Santosh Kumar Nayak
Ranch Hand
Posts: 143
Eclipse IDE IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 262
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1L? What is that?

Are you referring to the serialVersionUID?
 
Santosh Kumar Nayak
Ranch Hand
Posts: 143
Eclipse IDE IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I am referring to the value of SerialVersionUID.
 
Heena Agarwal
Ranch Hand
Posts: 262
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, don't know..

Pass..
 
Henry Wong
author
Marshal
Pie
Posts: 21115
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
Eclipse IDE IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 262
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul, Henry.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic