Patch: Code to dump serialized objects

Bryce McKinlay bryce@albatross.co.nz
Fri Nov 3 00:26:00 GMT 2000


Warren Levy wrote:

> Folks,
> I've instrumented java.io.ObjectInputStream to work as a serialized object
> dumper by reworking the commented out debug statements in the module.
>
> Now, if you've configured with --enable-libgcj-debug and call the static
> method java.io.ObjectInputStream.setDump(true); you will see the contents
> of the serialized object printed out for you as it is deserialized with
> readObject().  This can be useful if you are trying to implement
> serialization for a special case class and you're trying to understand
> the (sometimes limited) Serialized Form doc better.
>
> I've made the code conditionally compiled this way to optimize things a
> little bit and to avoid this accidently being turned on in production
> code.  Enjoy!

Hi Warren,

This sounds cool! However, since we're trying to create a _compatible_ Java implementation, adding new public methods to the
standard classes is a bad idea!

Instead, I would suggest that this stuff gets activated via a system property (eg "gcj.dumpobjects") that can be set either by
calling "System.setProperty()" or by using the -D option at compile-time.

Even better, why not make a small utility (ala 'jcf-dump') that hooks into ObjectInputStream and gets installed with libgcj, ie
'ser-dump' or something?

regards

  [ bryce ]




More information about the Java-patches mailing list