SerialVersionUIDAdder generates an incorrect serialVersionUID under 1.6 VMs for anonymous classes
Feeding the attached class (when compiled under 1.6) through an adapter chain
containing just the SerialVersionUIDAdder (and then dumping) generates the
following output:
// class version 50.0 (50)
// access flags 48
final class Test$1 extends Test {
// compiled from: Test.java
OUTERCLASS Test null
// access flags 8
static INNERCLASS Test$1 null null
// access flags 0
<init>()V
L0
LINENUMBER 4 L0
ALOAD 0
INVOKESPECIAL Test.<init> ()V
RETURN
MAXSTACK = 1
MAXLOCALS = 1
// access flags 24
final static J serialVersionUID = -76581618747421564
}
The calculated serialVersionUID is different from the value serialver reports:
Test$1: static final long serialVersionUID = 7846639601304304217L;
The value serialver reports is the same as on 1.4 and 1.5, which ASM correctly
matches in those VMs.
The only difference between the compiled classes appears to be the access flags
of the inner class: 1.5 and 1.4 report ACC_SUPER, 1.6 reports
ACC_SUPER|ACC_FINAL. However my reading of the 1.6 Sun source
(hotspot/src/share/vm/oops/instaceKlass.cpp:compute_modifier_flags) indicates
that the current implementation is correct (i.e. the class access flags are
ignored for inner classes, and the access flags contained in the InnerClass
attribute entry are used instead).
I'm at a loss to explain this, but I've reproduced the failure on three
different 1.6 VMs on three different platforms (RHEL, Ubuntu, Mac OS X).
Thanks,
Chris
P.S. I'm aware that serializing an anonymous inner class is not generally
recommended.