JavaMemoryModel: Previous discussions of final fields: final fields can only be set once in constructors

From: Bill Pugh (pugh@cs.umd.edu)
Date: Mon May 17 2004 - 14:57:52 EDT


This topic has come up several times (October and December of last
year), and I keep on forgetting to review all the previous
discussions.

Section 2.9 of the JVM spec says:

> Both class and instance variables (static and non-static fields) may
> be declared final. Once a final field has been initialized, it always
> contains the same value. If a final field holds a reference to an
> object, then the state of the object may be changed by operations on
> the object, but the field will always refer to the same object.

Section 4.5 of the JVM spec say that if a field is marked final:

> Declared final; no further assignment after initialization.

So between those two rules, and the fact that the JSR-133 spec has
stated so for a long time,
I am going to conclude that the Tiger spec will be that final fields
may only be set once
via bytecode.

We will reconsider for compelling reasons, but otherwise lets just take
this
as given and not open up the discussion again.

        Bill

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



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