Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

serialisation question  RSS feed

 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
When we want to make a class serilizable we implement the Seriliazable interface.
Now how does the JVM treat this class differently. Why is that we can only serialize those classes which implement the marker interface Serializable.
and cannot serialize teh one that do not implement Serializable.
What does a JVM do to treat them separately
Rgrds
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Implementing Serializable is just a message to the JVM that it is ok to attempt to serialize/deserialize the class in question. If your class does not implement the interface, the JVM will always throw an exception if that class is attempted to be serialized or deserialized.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!