Serialization between gcj- and javac compiled classes?
Tom Tromey
tromey@redhat.com
Wed May 26 17:09:00 GMT 2004
>>>>> "David" == David Daney <ddaney@avtrex.com> writes:
David> I don't know how libgcj calculates the serialVersionUID, but my
David> reading of the serialization specification is that if the identical
David> class exists in two different runtimes (Sun's and libgcj for example)
David> that the serialized form is compatible even without the explicit
David> serialVersionUID.
We really need a faq... this should be in it.
For a given .class file, we believe libgcj will compute the same
serialization UID that any other JVM will compute. I.e., it is
compatible.
The problem is with java compilers. Synthetic methods are included in
the UID computation, but there is no standard for names, types,
arguments, etc, to such methods. So, a given .java file compiled by
different compilers will yield different UIDs.
The fix for this is to declare serialVersionUID in your source. This
is a good defensive measure if you plan to actually rely on
serialization and might want to switch compilers some day. I think
Sun even recommends this, but I don't have a link.
Tom
More information about the Java
mailing list