Re: JavaMemoryModel: Final Means Different Things To VM and Java Language. Does That Impact JITs?

From: Allan Kielstra (
Date: Tue Sep 30 2003 - 18:18:08 EDT

Thanks, Bill, for the observation:

>The rules on final fields being set exactly once are part of the
>JVM/classfile specification. A classfile in which a final field is
>written to outside the constructor (or either zero or more than once
>during construction) is an invalid classfile that should be rejected
>by the JVM with a verification error.

>So the example below would be rejected by the JVM if MyFieldJ was final.

Here's the class file without the change: (See attached file:
finalt1.private.class)and here it is with the hack: (See attached file:

Unfortunately, our (IBM's) verifier accepts either version without
complaint as does the Sun JDK. So, perhaps I need to lobby to have the
behavior of the verifier made more stringent? How formally defined is the

Allan Kielstra
IBM Canada Lab
Phone: +1 (905) 413-3558 T/L 969-3558

JavaMemoryModel mailing list -

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:51 EDT