Community
Participate
Working Groups
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.
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.
*** This bug has been marked as a duplicate of 30209 ***