• Post Reply Bookmark Topic Watch Topic
  • New Topic

Serializable interface  RSS feed

 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, By making a class that implements Serializable, How JVM can save the state of an object. There should be some code/logic behind the scenes or somewhere that cannot be seen in Serializable interface. Could you please share that?
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code is in the java.io.ObjectOutputStream and ObjectInputStream classes. The JDK comes with the source code of all classes in a file called src.zip (somewhere in the JDK installation directory), so you can check it out yourself. The code is heavily commented.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java provides automatic serialization which requires that the object be marked by implementing the java.io.Serializable. Implementing the interface marks the class as "okay to serialize," and Java then handles serialization internally. There are no serialization methods defined on the Serializable interface, but a serializable class can optionally define methods with certain special names and signatures that if defined, will be called as part of the serialization/deserialization process.

have a look on the Specification and a sample tutorial
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!