RFR(s): 8023541 Race condition in rmid initialization

Doug Lea dl at cs.oswego.edu
Fri Jan 31 13:49:41 UTC 2014

On 01/31/2014 08:32 AM, Paul Sandoz wrote:
> On Jan 30, 2014, at 11:02 PM, Stuart Marks <stuart.marks at 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.


More information about the core-libs-dev mailing list