Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

serial  RSS feed

 
arjun krishna
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any body explain me what is the serialVersionUID ?
Where it is used?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Java in General -- this is a question about Java, not Object-Oriented Scripting.
 
Henry Wong
author
Sheriff
Posts: 22827
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by arjun krishna:
Can any body explain me what is the serialVersionUID ?
Where it is used?


When you serialize an object to a datastream, one of the items created is a version ID. It is basically some sort of checksum based on the instance variables, their types, etc. They way, if you change the class, and try to create an instance from the serialize data, it will fail -- as the class has been changed.

Unfortunately, it may too sensitive. So they allow the programmer to create the checksum. If you add a variable "serialVersionUID", it will use that as the checksum, instead of calculating it.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!