• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serialization

 
Manish Malhotra
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34974
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic