At 12:47 PM -0700 8/3/01, Jerry Schwarz wrote:
>>* If you have a class that is immutable, and all instance fields of 
>>that class are final, then you get special race-proof immutable 
>>semantics: Any thread that obtains, in any way, a reference to an 
>>instance of that class sees the initialization done by the 
>>constructor for that instance.
>
>It had been my understanding of the previous material by Bill that 
>the rule was intended to be that if any field was final then you 
>would get the race-proof immutable semantics.  Did I misunderstand 
>or has there been a change?
No. We are working from ground zero, trying to justify the proposed 
semantics. The above rule for immutable objects is a bare minimum 
that we need to support. The question is, how do we extend that to 
get something that seems reasonable, and just a special rule for 
objects that have only final fields.
>
>I think the "any" rule is better than the "all" rule because it is 
>less fragile for maintenance . That is, Java programmers will think 
>they can add a private non-final field to a class as long as they 
>ensure all uses are properly synchronized.  This is the case under 
>the "any" rule, but not under the "all" rule.
Neither "any" or "all". Allowing any one final field to change the 
semantics of the entire object is too nasty and ugly (particularly 
given the possibility of final fields being added in subclasses), and 
requiring all fields to be final is too restrictive.
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:34 EDT