• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

about serealization

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi!
some where i heard about serealization,if you are implementing the serealizable interface for a class,all the super calsses of that class must be serealizable. is this statement is true?
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, that's not true. If you declare your class Serializable, it can be serialised, even if its superclasses are not declared Serializable. The most obvious example of this is that all classes inherit java.lang.Object, and that's not Serializable!

However, you do have to give consideration to what your superclasses are, before you declare your class Serializable. Some classes are clearly unsuited to serialisation. Unfortunately, I don't know of any way of declaring your class unserialisable. Sounds like an application for an annotation?
 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As for making a class unserializable do not implement the Serializable interface. But if the parent class or anyone class in the hierarchy does that the class would automatically become serializable. Try using the readResolve method. Though it would not make the class unserializable but you can throw an Exception to the caller to convey that this class cannot be serialized.
[ June 07, 2007: Message edited by: Anupam Sinha ]
 
Nareshkumar Kapilavai
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much to all..
in case of object class.. it does't have any state. so not required to serialize. so i thought it is not a problem with object class.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic