Re: JavaMemoryModel: Are this$x fields final?

From: Sylvia Else (syljmm32@cryogenic.net)
Date: Mon May 24 2004 - 19:25:55 EDT


At 05:26 PM 24/05/2004 -0400, Bill Pugh wrote:
>It isn't part of JSR-133.
>
>Gilad, it should be part of the JLS/JVM spec that the this$x fields (that
>link an instance of
>an inner class to the enclosing instance) are final.
>
>Is that the case? The 1.1.8 inner class specification doesn't say so (and
>gives an example
>where it isn't final).
>
> Bill

We shouldn't conflate the qualified 'this' construct in the language with
the this$x fields in the implementation.

Prior to JSR133's freeze semantics for final fields, it would not have been
meaningful for the language spec to say that qualified 'this' was, or was
not, final. As a result of those semantics, and to take advantage of them,
programmers need to know whether they can treat qualified 'this' as final,
or whether they'd need to introduce an express final field to achieve the
required effect. Making qualified 'this' final has a potential
implementation cost, but so does adding an otherwise redundant field.

So even if it's argued that this isn't really a JSR133 matter, the question
is still deserving of a definitive answer.

Sylvia.

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