This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Serialization between gcj- and javac compiled classes?


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]