At 03:46 PM 5/26/2004, David Holmes wrote:
>Rather then dictate implementation can we not simply state that for the
>purposes of the JMM, references to the enclosing instance of an inner
>instance behave as-if they were accessed through a final field of the inner
>instance?
Creating an "as-if" rule is the proper way to proceed. References to this$x
are obviously implementation hacks. But the above isn't the right
rule. What programmers need is a guarantee that references to an class
always work. That is, they never generate a null pointer. Personally I
think this is implicit in the language definition of inner classes and JSR
133 doesn't need to say anything about it. But I wouldn't object to some
clarification.
If people need more synchronization than that then they should implement it
themselves. Saying that the inner class always has a final field has
implications for its constructors that we don't need. It associates being
an inner class with a property (how it's constructors behave) that doesn't
seem to have any relationship to the property of being an inner class.
>David Holmes
>
>-------------------------------
>JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
-------------------------------
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