On 01/31/2014 08:32 AM, Paul Sandoz wrote:
On Jan 30, 2014, at 11:02 PM, Stuart Marks <stuart.ma...@oracle.com> wrote:
Maybe. I'd guess that the new JMM will stick to covering well-behaved programs 
(e.g. ones that adhere to safe publication). The difficulty with issues like 
this one is that once publication has occurred unsafely, we have to figure out 
how to drag it back into the safe area. There are probably too many ways to 
write unsafe programs for the JMM to cover them in a simple fashion.


For your delectation:

   http://www.cliffc.org/blog/2011/10/17/writing-to-final-fields-via-reflection/

   http://www.cliffc.org/blog/2011/10/27/final-fields-part-2/


Simplifying final field rules is definitely on the agenda for JMM9
revisions. My guess is that the JMM per se will specify only the
memory ordering effects, and for the most part leave the question
of when reloads are suppressed as a JVM quality of implementation issue.

While I'm at it, I think Stuart's current approach seems fine.
Whenever you have no choice except to leak/publish in a constructor,
use volatiles to track initialization.

-Doug


Reply via email to