[concurrency-interest] Volatile stores in constructors, disallowed to see the default value

Aleksey Shipilev aleksey.shipilev at oracle.com
Thu Nov 28 01:27:32 EST 2013

On 11/28/2013 02:46 AM, David Holmes wrote:
>> In order to answer what outcomes are possible we need to dump the
>> usual/partial/misleading "reorderings" and "happens-before" mindset, and
>> get to the ground of spec. That is, we need to construct the possible
>> traces and see if those traces are committable, as per JLS 17.4.8.
> And therein lies your mistake. The "happens-before mindset" as you put it is
> what determines what the legal executions are. It was obvious from
> happens-before considerations that your premise was invalid.

Happens-before alone is not enough to mandate the semantics of Java
Memory Model. Even though it can cover the significant part of the
behaviors, the complete behavior of the model is governed by
well-formedness of executions, as per JLS 17.4.{6-8}. The classic
example (even shown in spec!) when the happens-before consistent program
produces causality violations.

> Q.E.D

So, there was nothing "obvious" unless you have the concrete proof. The
only reasonable way to prove this particular thing *was* to show the
committable traces leading to particular results (like I did), *and* to
find flaws in the reasoning in larger JMM. "La-la-la, happens-before,
la-la-la" is hardly a proof, even though the conclusion is the same in
this particular case. Make no mistake about it.


More information about the Concurrency-interest mailing list