JEP 171: Fence Intrinsics

Doug Lea dl at cs.oswego.edu
Mon Dec 3 12:00:12 PST 2012


On 12/03/12 13:25, David Chase wrote:
> I'll defer to your judgement on the JMM issues, but from a user (programmer)
> POV, does this distinction make a difference?  I think their (in)ability to
> write "portable" code (across style checkers, across class loaders) would be
> a big deal.
>
> How about "sun.misc.VM" instead?  Unsafe seems to be booby-trapped against
> use by non-system classloaders; I don't see how that is necessary here.
>

Placing in Unsafe is in the tradition of the "voids your warranty".
The moral-hazard faction (to which I'm a little sympathetic)
really don't want ANY programmers accidentally using such methods.
And rather than scrapping fences for yet another JDK release,
my hope is that establishing in a way that completely precludes this,
even at the expense of usability in other contexts, is
uncontroversial enough to accept.

I'm also hoping that for JDK9, there will be some nicer way to
support all memory-model-related special operations
without Unsafe. If nothing else, keeping it painful to use for
now might hasten efforts to improve this situation.

-Doug


More information about the hotspot-dev mailing list