Community
Participate
Working Groups
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;
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.
*** This bug has been marked as a duplicate of 10104 ***
Are you using the same version of the JDT on both side? In the command line and to run the application inside Eclipse?
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.
Actually, this is not a dup then.
Closed as user error.