Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About serialVersionUID

 
Tanzy Akhtar
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can somebody explain what is serialVersionUID and when to define in the class?

I saw such a class having serialVersionUID defined more than once and with the same name and value like

What's the need of this?

Thanks,
Tanzy.
 
manoj r patil
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just google it, and you will get what it is used for. In short, it is used in serialization by JVM.

I was wondering how come you can have serialVersionUID defined more than once. In fact you can not have any variable definition more than once at the same level (class/local).
 
Campbell Ritchie
Sheriff
Pie
Posts: 48964
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The idea of the SUIDis that when you have two instances of the same class with the same SUID, the JVM assumes they are from the same class object. If you have different SUIDs, the JVM may assume they are from different versions of the class, and the objects may not be de-serialized.
And I agree it is very peculiar to have two definitions in the same class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic