Serialization issue

Hi there,

I have a class A which has an instance of class B and it is not a transient. Class A is serializable and B is NOT. When I serialize class A it throws an exception "java.io.NotSerializableException". Assuming class B is third party where I don't have any control. In this senario what is the best solution to serialize class A? Or atleast how can I re-initialize object B while deserialization?

Any help greatly appreciated..

Thanks!

[468 byte] By [vmeghraj] at [2007-9-30 17:35:26]
# 1

You can define special readObject and writeObject methods in your class to customize the serialization mechanism (if you can't make the field transient). See the class description of ObjectOutputStream and the serialization spec for details: http://java.sun.com/j2se/1.4/docs/api/java/io/ObjectOutputStream.html

http://java.sun.com/j2se/1.4.2/docs/guide/serialization/spec/serialTOC.html

jsalonen at 2007-7-6 13:58:54 > top of Java-index,Administration Tools,Sun Connection...
# 2
Thanks for your reply. It worked.
vmeghraj at 2007-7-6 13:58:54 > top of Java-index,Administration Tools,Sun Connection...