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

Serializable interface implementation  RSS feed

 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Whenever we implement the Serializable interface while writing a JavaBean class, I have seen that invariably it contains the following line of code:



What is the meaning of and purpose of writing this?
 
harshvardhan ojha
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is meant to keep version for your class so that it won't try to deserialize objects having incompatible versions. otherwise it will throw InvalidClassExceptions for incompatible versions.
 
Campbell Ritchie
Sheriff
Posts: 53750
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That actually means that you are using an IDE where you have set an option to include an “default” SUID number in every Serializable class. I think you should take that option off.

Look here, where you will find links to discussion of serialisation, which will help explain what an SUID is.
 
Campbell Ritchie
Sheriff
Posts: 53750
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another discussion here. See which is the links I quoted is better.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!