jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Serialization" Watch "Serialization" New topic


Manish Malhotra

Joined: Apr 05, 2003
Posts: 29
Dear friends,
What are the extra property added by java when a class implements Serailizable interface.
Because Serailizable is a no method inter.
We make that particular classes object persistent, that is OK but else then it, there should be something reason to declare this interface.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Serializable is simply a tagging interface. It instructs the JVM that it is OK to serialize objects of the implementing class either for pesistance or transmission. Why does the JVM insist that an object be Serializable before persisting or transmitting it? In a word security. The same is true of the Cloneable interface but there are issues other than security involved with Cloneable since the default Object.clone() only produces a shallow copy of the object which can cause problems with classes that hold references to mutable objects. Back to Serializble, RMI requires an object to either implement Remote (yet another tagging interface) or Serializble for transmission. RMI is used in Java's version of distributed client/server architechture as well as EJBs.

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33106

It's not required, but it's a good idea to have a static variable called serialuid. This number can be generated using the serialver tool. It helps the JVM serialize the class slightly faster because it doesn't need to calculate the serialuid each time.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link: http://aspose.com/file-tools
subject: Serialization
It's not a secret anymore!