File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes serialization question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "serialization question" Watch "serialization question" New topic
Author

serialization question

Mike Mitchell
Ranch Hand

Joined: May 28, 2008
Posts: 38
hi. I was trying to whip something up to demonstrate that if a serializable object's parent is not serializable, than any inherited attributes will not be serialized.

However, when I run TestSerial below, I get the following exception. Having trouble understanding why. Anybody see the problem? If I make Food implement Serializable, it runs without exception.

Thanks much,
Mike




[ July 20, 2008: Message edited by: Mike Mitchell ]

SCJP 5, SCWCD 5
Don Solomon
Ranch Hand

Joined: Jul 20, 2008
Posts: 48
Hey Mike,
I had to add a default constructor to Food Class for your program to work; which I believe is a requirement for non-Serializable supers.

Anyone correct me if I am wrong.

Thanks
[ July 20, 2008: Message edited by: Don Solomon ]

Software development is an exercise in thinking not coding.
kaushik vira
Ranch Hand

Joined: Feb 01, 2007
Posts: 102
Ya.. Default constructor in parent class is mandatory if you are relaying on default serialization.


kaushik Vira
-------------------------------------
SCJP, Preparing SCWCD..
Mike Mitchell
Ranch Hand

Joined: May 28, 2008
Posts: 38
Thanks Don and Kaushik. That was it -- I needed a default constructor in the non-serializable super class.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: serialization question