RE: JavaMemoryModel: Unexpected weakness/divergence in old JVM spec of final fields

From: Bill Pugh (
Date: Mon Dec 29 2003 - 07:57:27 EST

At 11:07 AM +1000 12/29/03, David Holmes wrote:
>Bill, this issue was raised in October (see mailing subject RE:
>JavaMemoryModel: Final Means Different Things To VM and Java Language.
>Does That Impact JITs?). Apart from the necessary but insufficient
>restriction in PUTFIELD, the description of the ACC_FINAL bit also
>defines semantics: JVMS Section 4.5 Table 4.4 - ACC_FINAL: Declared
>final; no further assignment after initialization.

OK, sorry I missed this.

>The current spec for ACC_FINAL already states this (in loose terms).
>Do we require that either:
>a) PUTFIELD/PUTSTATIC check for this; or
>b) that the verifier check for this?

I'm not sure it really matters where the check is done.

So, this suggests that it is acceptable for the VM to reject with a
either a class file format or verification error any classfile in
which a final field is initialized more than once.

However, since the current 1.5 VM doesn't reject them, we probably
can't require that VMs reject such classfiles, only encourage it.


JavaMemoryModel mailing list -

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