Article View: borland.public.jbuilder.java.swing
Article #9656Re: Serialization problem with JDK 1.2
From: John P. McGrath
Date: Fri, 11 Feb 2000 00:00
Date: Fri, 11 Feb 2000 00:00
48 lines
2767 bytes
2767 bytes
On Thu, 10 Feb 2000 10:37:26 +0100, Jean-Paul Bouzigues wrote:
> Using JDK 1.2, I need to serialize somes JCheckBox components
> which have associated toolTips. I've got the next message:
>
> java.io.NotSerializableException: javax.swing.ToolTipManager
It is never very easy to trace down why the serialization mechanism is
trying to serialize a particular object. Obviously, there is a chain of
non-transient references from the object you serialize explicitly to the
object in question, but tracing that chain can be difficult.
I have always avoided serializing Swing components. For starters, any
such components will not deserialize properly with a new version of the
JDK. You will note that the docs for all of the serializable Swing
components contain the following:
Warning: Serialized objects of this class will not be compatible
with future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications
running the same version of Swing. A future release of Swing
will provide support for long term persistence.
Some version of that message has been in the Swing docs for quite a
while, but the original version said:
Warning: serialized objects of this class will not be compatible
with future swing releases. The current serialization support is
appropriate for short term storage or RMI between Swing1.0
applications. It will not be possible to load serialized
Swing1.0 objects with future releases of Swing. The JDK1.2
release of Swing will be the compatibility baseline for the
serialized form of Swing objects.
Obviously, JDK 1.2 has come and gone, and Sun has not quite figured out
what to do with Swing serialization. It is a pretty complex problem.
Given all of the listeners and client properties that can be attached to
a component, it can be pretty tough to control what is Serialized.
In my code, I have avoided serializing any part of the UI. I serialized
the core "model" objects, and re-create the UI when I deserialize them.
I also store some selected state information from the UI, but never
serialize the UI objects themselves.
--
John P. McGrath
<JPMcGrath@fast.net>
<jpm@nscs.fast.net>
Technical Details
Message-ID:
<MPG.130d6abfe97b8303989786@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<87u04v$c5b1@bornews.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,d2dcd289d922d7d1 X-Google-Attributes: gid111d45,public From: John P. McGrath <JPMcGrath@fast.net> Subject: Re: Serialization problem with JDK 1.2 Date: 2000/02/11 Message-ID: <MPG.130d6abfe97b8303989786@forums.borland.com> X-Deja-AN: 584433787 References: <87u04v$c5b1@bornews.borland.com> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing