RFR 8159751: ObjectStreamClass: hide 'final' flag for anonymous classes

Roger Riggs Roger.Riggs at Oracle.com
Thu Jun 23 17:37:08 UTC 2016


Hi Dan,

I was concerned about inter-operation between versions because 
serialized objects
are passed between Java runtimes with different versions and both need 
to compute
the same serial version uid (if it is not explicitly declared). The 
older java runtimes will
compute the serial version uid without regard to your change.

If javac always turns on the ACC_FINAL bit and using -target 8 and then 
the class file
is executed in a Java 8 runtime, it seems like it would compute a 
different value
which would be in compatible change.  It might be safer to introduce 
this change
only with the new class file version number.

Roger



On 6/23/2016 12:55 PM, Dan Smith wrote:
>> On Jun 23, 2016, at 8:51 AM, Roger Riggs <roger.riggs at oracle.com> wrote:
>>
>> Hi Dan,
>>
>> Is setting ACC_FINAL for anonymous inner classes a unique feature of the latest bytecode version?
>> (javac -target 9)
>>
>> Was it always clear in class files with earlier bytecode versions?
> This is a choice that the compiler makes, subject to the constraints of the Language Specification.  At the moment, ACC_FINAL does not get set*.  The outcome I expect from JDK-8129576 is to always set it, regardless of target version, since that's what the spec has always said.  I suppose we could consider guarding the change on target version, but anyway that wouldn't affect the behavior of serialization either way, since this patch causes it to always ignore ACC_FINAL.
>
> (* Actually, we found a bug in which it sometimes gets set on the class's flags, but still remains unset in the flags provided by the InnerClasses attribute.  The latter is what you get from Class.getModifiers, so this bug hasn't affected serialization.)
>
> —Dan



More information about the core-libs-dev mailing list