Re: JavaMemoryModel: Issue with final fields

From: Jeremy Manson (jmanson@cs.umd.edu)
Date: Sat Feb 02 2002 - 16:55:34 EST


> Eliot Moss Writes:
>
> >>>>> "Cliff" == Cliff Click <Cliff.Click@sun.com> writes:
>
> Cliff> Yes it bothers me, but not a lot. You published a bogus Foo.
> Cliff> Anything that touches this bogus Foo is now Bogified (TM). You
> Cliff> and your program will be shot at dawn. :-)
>
> I agree with Cliff -- it bothers me. I would allow the compiler to do the
> transformation; but the fact that an improper publication leads to
> something bogus does not bother me ... so long as we can guarantee that the
> bogus value is type-safe!
>

Also, you could perform the optimization in some cases, if you were dead set
on it - as long as you were able to show that a reference to the object didn't
escape the constructor. This shouldn't be impossible to do in all cases.

> (Just like the fact that my concurrent collector may do something bad to
> programs with data races on non-volatile fields doesn't bother -- people
> who code things like that deserve nasty results.)

As long as the end result is type-safe and "not-out-of-thin-air". I had
gotten the sense from your previous message that at worst your GC will provide
a stale (but legitimate) value, right?

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



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