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

Doug Lea dl at cs.oswego.edu
Wed Nov 27 14:26:10 EST 2013

On 11/27/2013 02:06 PM, Vitaly Davidovich wrote:
> But either
> way, optimizations to avoid zeroing memory is an implementation detail and thus
> cannot be relied upon from JMM standpoint, which I think you're saying.
> The other issue is that even if we determine that volatiles don't get this
> treatment, if JVM is already ensuring it, it's not going to be practical to
> change it and risk hard to debug problems creeping in.  May as well update the
> spec now ...

Right. To summarize:

* Programmers do not expect that even though final fields are specifically
publication-safe, volatile fields are not always so.

* For various implementation reasons, JVMs arrange that
volatile fields are publication safe anyway, at least in
cases we know about.

* Actually updating the JMM/JLS to mandate this is not easy
(no small tweak that I know applies). But now is a good time
to be considering a full revision for JDK9.

* In the mean time, it would make sense to further test
and validate JVMs as meeting this likely future spec.


More information about the Concurrency-interest mailing list