[All]
JBuilder 4/5: "Include debug information" switch affects SerialVersionUID?
By: Josh Fletcher
Abstract: Explanation of known bug in JBuilder 4/5.
Question:
|
Should the "Include debug info" compiler switch affect the SerialVersionUID?
|
| |
Answer:
|
This is a known issue in JBuilder 4 and 5. It is not, however, a bug. There is no information that clearly states that what JBuilder is doing is wrong. It is simply different. Here is a description of what is going on:
When the class is compiled with debug information, JBuilder generates code to initialize member variables that are initialized to compile-time constants. This affects the Serialization Version UID for the class, since it creates a static initializer block. This will only occur for classes where all of the static final variables are initialized with compile-time constants.
JBuilder does this so that you can step through the code in the debugger while constants are being initialized.
There is a work-around that will eliminate the problem. If you create a static, non-final variable with an initializer, JBuilder and other compilers will always create the static initializer block, so the Serialization Version UID will be the same whether or not you compile with debug information. For example, add the the following to your class:
private static int DUMMY = 1;
The other (and potentially better) option is to explicitly specify the Serialization Version UID for the class.
|
| |