jdk9 VarHandle and Fence methods

Doug Lea dl at cs.oswego.edu
Fri Aug 21 23:21:17 UTC 2015

On 08/21/2015 01:58 PM, Gil Tene wrote:

>> On 08/21/2015 10:50 AM, Gil Tene wrote: ...
>>> - Is NotReallyVarHandle.setOpaque() more relaxed than a lazySet()? Or is
>>> it similar?
>> The unloved-but-necessary method setOpaque is setRelaxed with what amounts
>> to a compiler directive saying that the write must actually occur even if
>> other JMM rules would allow it to be optimized away. Usage should be rare.
>> Think IO.
> Ok, that makes more sense (as written above).
> I think the comment needs to make this semantic meaning clear.

Right. Doing so is challenging within the confines of not accidentally
revising the JMM inside the javadoc.

> The current one does not, leading to obvious questions.
> The IO example is a good one. It is probably more tricky to word when it
> comes to non-IO realms, as "write [to memory] must actually occur"

Yes. Most likely a formal spec would be in terms of not indefinitely
postponing reads/writes. Which is itself problematic because it
ultimately requires progress, which we try to avoid (over)specifying.


More information about the valhalla-dev mailing list