Bug 32227 - Serialization incompatibility with Sun's 1.4 compiler
Summary: Serialization incompatibility with Sun's 1.4 compiler
Status: RESOLVED DUPLICATE of bug 30209
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 RC1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-19 07:59 EST by Stephen Summerfield CLA
Modified: 2003-02-19 08:27 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Summerfield CLA 2003-02-19 07:59:05 EST
Problem is that Eclipse compiler creates incompatible classes in terms of 
serialization with Sun's JDK1.4(.0) compiler.

Problem is demonstrated in a simple test program:

import java.io.Serializable;
public class Test implements Serializable
{
    public static String cName = Test.class.getName();
}

Running serialver on classes generated by Eclipse and Sun's JDK (both set to be 
1.4) from the same source file  gives:

Eclipse: Test:    static final long serialVersionUID = 1400023213535622423L;
Sun    : Test:    static final long serialVersionUID = 2953822734317990598L;

Also causes problems debugging client/server programs (that use serialization).

If the line in the above program is changed to be:

    public static String cName = "Test";

both classes then have the same serialVersionUID.
Comment 1 Philipe Mulet CLA 2003-02-19 08:25:12 EST
Serialization is sensitive to compiler synthetic emulation, which is spec'ed 
nowhere in the JLS. This is unfortunate, and until the JLS covers it, nobody is 
either wrong or right on this front. Eclipse compiler and javac perform 
differently on unspecified behavior.

There is nothing we can do to improve this, matching a particular version of 
javac would not be acceptable (reciprocally one could argue they should match 
us).

In general, one should *always* serialize/deserialize against binaries 
generated by the exact same compiler (and even against a particular compiler 
version). Alternatively, serialization should ignore synthetics (AccSynthetic 
is a modifier used to tag all exotic additions to classfile which can break 
serialization). The JLS/serialization has been aware of this weakness for 
years, and never decided to resolve it.

Comment 2 Philipe Mulet CLA 2003-02-19 08:27:07 EST

*** This bug has been marked as a duplicate of 30209 ***