Name: dbT83986 Date: 03/04/99
I suppose the documentation on serialization is not aware
about the new java.lang.ref.* classes, e.g. WeakReference.
Another possibility: You simply didn't define a nice solution
for getting *small* object streams.
The online doc says (for ObjectOutputStream):
"The default serialization mechanism for an object writes the class of the object, the class signature, and the values of all
non-transient and non-static fields. References to other objects (except in transient or static fields) cause those objects to
be written also. Multiple references to a single object are encoded using a reference sharing mechanism so that graphs of
objects can be restored to the same shape as when the original was written."
This would mean that objects I regard as not important
would be serialized (they may be garbage collected at any time,
when my "master object" only holds a soft reference to it but
nobody else has a hard link to them).
I suppose a much cleaner definition would be to define that
serializing WeakReference objects leads to their inner reference
set to null. This would be a clean definition AND even better
means that my object streams get pretty small. When I like those
referenced objects to serialized I must have an object
that has hard links to them anyway.
This could be a nice solution for the problem of accidentially
serializing e.g. propertyChangeListeners, too. Those listeners
normally only need to be weakly referenced. When serialization
reaches a WeakReference, it simply could set the referent to
null and stop further traversion of the object graph at this
point. This change would make serialization "proxy aware".
(Review ID: 54597)
======================================================================