[jmm-dev] Specifying VarHandle acquire/release without ill effects

Nitsan Wakart nitsanw at yahoo.com
Fri Jun 17 13:02:18 UTC 2016

I think the effect you seek can be achieved by expanding on the acq/rel relationship. E.g.:

  * Returns the value of a variable, and ensures that subsequent
  * loads and stores are not **VISIBLY** reordered before this 
  * access **when matched with a release of same variable** .
  * ...
  Object getAcquire(Object... args);

  * Sets the value of a variable to the {@code newValue}, and ensures
  * that prior loads and stores are not **VISIBLY** reordered after this
  * access  **when matched with an acquire of same variable** ..
  * ...
  void setRelease(Object... args);

The wording is lame, but the intent is to make the guarantee depend on the relationship between acq and rel. If the relationship is void so is the guarantee.
This makes the optimization of TL variables, or any unmatched acq/rel if provable, valid.

More information about the jmm-dev mailing list