• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inheritance in serialization

 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K&B wrote-
If you are a serializable class, but your superclass is not serializable, then any instance variables you inherit from that superclass will be reset to the values they were given during the original construction of the object. This is because the non-serializable class constructor will run!

My question is that here object comes from serialization, not created using new. Then what invoke the constructor of non-serializable superclass?
 
Paul Clapham
Sheriff
Pie
Posts: 20723
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The deserialization code does that. In other words, something called by ObjectInputStream does.
 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Paul
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic