This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Serializable interface implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Serializable interface implementation" Watch "Serializable interface implementation" New topic

Serializable interface implementation

Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157


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?

~ Mansukh
harshvardhan ojha
Ranch Hand

Joined: Jul 26, 2007
Posts: 157

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

Joined: Oct 13, 2005
Posts: 43892
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

Joined: Oct 13, 2005
Posts: 43892
Another discussion here. See which is the links I quoted is better.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Serializable interface implementation
It's not a secret anymore!