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

From: Allan Kielstra (kielstra@ca.ibm.com)
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:
finalt1.privatefinal.class)

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
verifier?

Allan Kielstra
IBM Canada Lab
Phone: +1 (905) 413-3558 T/L 969-3558
kielstra@ca.ibm.com




-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



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