Re: JavaMemoryModel: Re: Are this$x fields final?

From: Sylvia Else (syljmm32@cryogenic.net)
Date: Thu May 27 2004 - 20:52:05 EDT


At 03:05 PM 27/05/2004 -0700, Jerry Schwarz wrote:

>Yes I understood that. What I was trying to say was that I don't think we
>want to provide the transitive guarantees for inner classes. I agree that
>the compiler must guarantee that the correct value of the implicit pointer
>(i.e. this$0) is always seen. What I disagree with is the idea that
>because we need that guarantee it makes sense to give the stronger
>transitive closure guarantee for the rest of the actions of the Inner
>constructor.
>
>With regards to this$0 itself I would want a very strong guarantee. Namely
>that it is never seen to be null.

The JVM does not know about inner classes, so the option of guaranteeing
the visibility of the write to the this$x field, without its being final or
volatile, does not exist. Of the two, final makes more sense to me, and
seems likely to have a lower cost.

On this basis, my example is largely irrelevant. The real issue is the
NullPointerException scenario that Bill highlighted.

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:08 EDT