[concurrency-interest] DirectByteBuffers and reachabilityFence

Doug Lea dl at cs.oswego.edu
Thu Dec 10 19:14:54 EST 2015

On 12/10/2015 07:56 AM, Andrew Haley wrote:
> On 12/10/2015 12:51 PM, Vitaly Davidovich wrote:
>> I can see a few reasons against extending `this` lifetime at this stage of
>> java's life, but what were the objections last time(s) this came up?
> Basically twofold.  Mostly efficiency, but also a reluctance to change
> long-settled language semantics.  Making changes to something as
> fundamental as this is always much tricker than people expect.  The
> great advantage of reachabilityFence is that we can do it without a
> lot of complex argument and politics.

Like Andrew and others who have seen periodic protracted
discussions of this issue over the past decade or so, I'm not
too optimistic.

But this is also one reason for considering a @Finalized annotation
for fields (not classes!), that would give essentially this
guarantee only in those cases it was requested. Compilers would
translate methods/blocks accessing @Finalized field r
(as in .. use(r); ...)  to  the equivalent of:
   try { ... use(r); ... } finally { reachabilityFence(); }

In the mean time, users can at least arrange this manually though.
There is no reason to believe that the performance impact would
be any different in manual vs automated forms, as long as some of
us are willing to help hotspot minimize it.


More information about the Concurrency-interest mailing list