aspose file tools
The moose likes Beginning Java and the fly likes Serializable interface implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Serializable interface implementation" Watch "Serializable interface implementation" New topic
Author

Serializable interface implementation

Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1142

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?


~ Mansukh
harshvardhan ojha
Ranch Hand

Joined: Jul 26, 2007
Posts: 157
    
    1

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

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

Joined: Oct 13, 2005
Posts: 32708
    
    4
Another discussion here. See which is the links I quoted is better.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Serializable interface implementation
 
Similar Threads
6 Qs
Serielizible?
Can we find the code which makes the object serializable?
Marker Interface
Class Casting