Bug 51843 - serialVersionUID of JComponent in Eclipse does not match Sun JDK
Summary: serialVersionUID of JComponent in Eclipse does not match Sun JDK
Status: RESOLVED INVALID
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: 3.0 M7   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-12 10:39 EST by Andrew Morrow CLA
Modified: 2004-02-12 17:39 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 Andrew Morrow CLA 2004-02-12 10:39:53 EST
This is not a compiler issue!  I know about 10104, etc.
Eclipse does not compile javax.swing.JComponent.  Yet Eclipse still produces a 
serialVersionUID that is different from that generated by Sun JDK, from the 
same class file.  Introspection shows no changes.  Mmost other swing classes 
match OK (and, of course, they do not have an explicit serialVersionUID).

Even if this is "not a bug", please explain.

Here is a test program and results

import java.io.ObjectStreamClass;
import java.io.Serializable;
class ShowSUID implements Serializable {
 public static void main(String args[]) throws Exception{
  Class cl = Class.forName( args[0] );
  ObjectStreamClass myObject = ObjectStreamClass.lookup( cl);
  System.out.println("myObject="+myObject);
// long theSUID = myObject.getSerialVersionUID();
 }
}

% uname -a
SunOS ultra60 5.9 Generic_112233-10 sun4u sparc SUNW,Ultra-60
% java -version
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)
% java ShowSUID javax.swing.JComponent
cl=class javax.swing.JComponent
myObject=javax.swing.JComponent: static final long serialVersionUID =
        5896976265092562486L;

(same in Eclipse)

cl=class javax.swing.JComponent
myObject=javax.swing.JComponent: static final long serialVersionUID =
        -7908749299918704233L;
Comment 1 Olivier Thomann CLA 2004-02-12 11:50:47 EST
The problem is simple.
JComponent is using the class literal (Name.class) to load a class. The code
generation is different for this pattern between javac and the Eclipse compiler.
That would be enough to get a different serialVersionUID.

Note that this will change also with the JDK1.5 where they use the bytecode ldc
to load a class without initializing it.
Comment 2 Philipe Mulet CLA 2004-02-12 12:58:49 EST

*** This bug has been marked as a duplicate of 10104 ***
Comment 3 Olivier Thomann CLA 2004-02-12 16:02:28 EST
Are you using the same version of the JDT on both side? In the command line and
to run the application inside Eclipse?
Comment 4 Andrew Morrow CLA 2004-02-12 17:15:20 EST
My apologies: This was a configuration issue.  I had two JVM's installed: 
1.4.1 and 1.4.2 and Sun modified JComponent such that the serailVersionUID 
changed.

The scenario was that I created by workspace with the default J2SE that came 
with Solaris 9 (and is installed in /usr/j2se).  I then upgraded to 1.4.2 and 
updated the /usr/java link to point to my 1.4.2 JDK.  This means 
that /usr/bin/java points to the 1.4.2, but my workspace and launches had 
memorized the JDK in /usr/j2se, perhaps by dereferencing 
the /usr/bin/java, /usr/java symlinks, or perhaps by knowing that /usr/j2se is 
the natural, default JVM for the machine.

Of course, all I need to do is force it all to one or the other.  Also, I 
noticed that the Solaris GUI seems to just label it "j2se", rather 
than /usr/j2se, which might cause more confusion than it is worth.  Again, 
perhaps this is because Sun does have a concept of the default JDK for the 
machine installed via packages such as  SUNWj3rt.

Apologies to all who find this tiresome, but perhaps this message will assist 
others who goes through the same scenario.
Comment 5 Philipe Mulet CLA 2004-02-12 17:39:02 EST
Actually, this is not a dup then. 
Comment 6 Philipe Mulet CLA 2004-02-12 17:39:26 EST
Closed as user error.