|
|
The serialVersionUID from classes compiled by JB4 doesn't match Sun's javac 1.3 or 1.4. |
| A recent change in Sun's javac has created a new incompatiblity between
class files compiled by it and by JBuilder's compiler.
Inner classes gain access to their container class variables using auto-generated access methods created by the compiler as needed. The specification declares that these methods should be named "access$n" and this is the form javac 1.2.2 (and earlier) and other compilers have used (including JBuilder's). The problem appears in javac 1.3 and 1.4, which has changed the name of the access methods to "access$nnn" meaning the number appended to the name now contains leading zeroes. Because the serialVersionUID is computed using the method names within the class, the change in the access methods changes the computed value. So, the same class file compiled by javac 1.2.2 and 1.3 will have different values! Of course, this applies to JBuilder's compiler, also. The only way to get around this problem is to ensure all copies of your class files were compiled by the same compiler, or by compilers known to produce compatible method names.
The DUMMY static constant trick mentioned elsewhere will not fix this
problem, only recompiling with a compatible compiler will do it.
| |
| See also:
| |
| John McGrath [TeamB] writes:
I have not looked at this for a while, and I see that Borland has changed the compiler to always generate the static initializer block, regardless of whether the -g option is used. It seems as if Java compiler developers have been grappling with this issue, as different versions of compilers handle this differently. I compiled the following program with various compilers, both with and without the debug (-g) option.
public class SUID implements java.io.Serializable {
public static final String suid = "suid";
}
As you can see, the results are somewhat mixed.
Debug (-g)
----------
Compiler Yes No
--- --
JDK 1.1.8 N N
JDK 1.2.2 N N
JDK 1.3 N N
JDK 1.3.1 N N
JDK 1.4 N Y
Jikes 1.12 N N
Kaffe 1.4F Y Y
JBuilder 4 N Y
JBuilder 5 Y Y
JBuilder 6 Y Y
I am going to see if I can find out more about this. I presume that the reason you are concerned about this is that the default SerialVersionUID varies depending on the compiler. The way to fix that is to add a static non-final variable with an initializer into your class. Then, you will have a static initializer with all compilers and there will be no compatibility issues. For example:
private static int DUMMY = 1; 2002-Mar-03 2:08pm gyles19@visi.com | |
| Another source of serialVersionUID mismatch is the use of rmiregistry in a JVM outside of the JVM that's running the application. You must address the 'rmi codebase' issues and/or call java.rmi.registry.LocateRegistry.createRegistry()
within your application.
| |
| [Append to This Answer] | |
| 2002-Apr-17 6:02am |
| Previous: |
|
| Next: |
|
| ||||||||
|
Java Community
Java Tools |
Code Central JB OpenTools |
Community Recent Threads |
Borland Chat Chat FAQ |
||||||||||||||
|
Feature Matrices 3.0 | 3.5 | 4.0 5.0 | 6.0 | 7.0 |
Shop for JBuilder |
JBuilder Downloads and reg keys |
Report Piracy | ||||||||||||||
|
Online Manuals 4.0 | 5.0 | 6.0 7.0 |
Borland DevSupport's Bug/RFE Form Quality Central Client |
JB Patches & Updates |
JBuilder FAQs TIs | ||||||||||||||
|
JBuilder Newsgroups |
Tamaracka's News Archive |
Mr. Haki's JBuilder Machine |
JGuru's JBuilder FAQ |
||||||||||||||
|
Sun's Bug Parade |
|||||||||||||||||
|
|||||||||||||||||