Bug 71485 - Serialization incompatibility with Sun compiler
Summary: Serialization incompatibility with Sun compiler
Status: RESOLVED DUPLICATE of bug 10104
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-05 11:53 EDT by Lukasz Skowronski CLA
Modified: 2004-08-05 16:12 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukasz Skowronski CLA 2004-08-05 11:53:43 EDT
Here are two simple classes which present incompatibility between Sun and 
eclipse compilers.


public class SerializationTest implements Serializable {
 private void dummy() {
  Class c = String.class;
 }
}


public class Test {
 public static void main(String[] args) {
  Class c = SerializationTest.class;
  ObjectStreamClass osc = ObjectStreamClass.lookup(c);
  System.out.println("serialVersionUID for " + c + " is " +
osc.getSerialVersionUID());
 }
}

These classes compiled with Sun compiler produce other result than when 
compiled with eclipse compiler.
I suppose the reason of this behavior is that both compilers create static 
variable of Class type but
1. Sun calls it class$java$lang$String
2. eclipse calls it class$0
3. Sun also creates a method with "static Class class$(String s)" signature

Regards
Luke
Comment 1 Olivier Thomann CLA 2004-08-05 16:12:25 EDT
This is not a bug in the Eclipse compiler. If you want to use the default
serialization, you should provide the serialVersionUID private field. If you
don't, you depend on the compiler used to compile your class.
Search for serialization in bugzilla for other bug reports related to the same
issue.

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