This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inheritance in serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inheritance in serialization" Watch "Inheritance in serialization" New topic
Author

Inheritance in serialization

Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 245

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?


Astha - OCPJP 6 (90%)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

The deserialization code does that. In other words, something called by ObjectInputStream does.
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 245

thanks Paul
 
jQuery in Action, 2nd edition
 
subject: Inheritance in serialization