API review of VarHandles

Vitaly Davidovich vitalyd at gmail.com
Fri Jan 22 11:15:28 UTC 2016

On Friday, January 22, 2016, Andrew Haley <aph at redhat.com> wrote:

> On 22/01/16 00:01, Vitaly Davidovich wrote:
> > I think the get/setOpaque methods need a bit more explanation ("opaque"
> is
> > an odd naming choice, IMO).  Specifically, it says the operations are
> done
> > in program order but have no effect on inter-thread ordering/visibility.
> > Is this spec verbiage for a full compiler-only fence?
> It's like C++ memory_order_relaxed, I guessed.  I understand that but
> not "opaque".

I thought so too before reading opaque javadoc (no pun intended).  C++
relaxed says nothing about order though, only atomicity.  Opaque doesn't
mention atomicity at all.

I'm guessing opaque is compiler only fence because a method that a compiler
doesn't inline (as an example) is considered "opaque" to the compiler and
serves like a fence.  Perhaps that's how opaque ended up here.  At any
rate, I think it's a poor name.

> Andrew.

Sent from my phone

More information about the valhalla-dev mailing list