This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Serialization between gcj- and javac compiled classes?
- From: Tom Tromey <tromey at redhat dot com>
- To: David Daney <ddaney at avtrex dot com>
- Cc: Bryce McKinlay <mckinlay at redhat dot com>,Martin Egholm Nielsen <martin at egholm-nielsen dot dk>, java at gcc dot gnu dot org
- Date: 26 May 2004 10:15:45 -0600
- Subject: Re: Serialization between gcj- and javac compiled classes?
- References: <c91ni7$lmj$1@sea.gmane.org> <40B4BC64.5010801@redhat.com><40B4C317.1000505@avtrex.com>
- Reply-to: tromey at redhat dot com
>>>>> "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