[concurrency-interest] DirectByteBuffers and reachabilityFence

Doug Lea dl at cs.oswego.edu
Wed Dec 9 07:46:38 EST 2015


On 12/09/2015 05:33 AM, Andrew Haley wrote:

>> In my opinion, the current lack of optimization (accidental or not)
>> should be somehow encoded/made intentional.
>
> I have in the past argued that methods of classes with finalizers
> should automagically extend the lifetime of the "this" object.
> However, I was on the losing side, and reachabilityFence() is the
> compromise result.  That's okay, really: it solves the practical
> problem.
>

I don't think anyone "lost" these arguments, but further action
was postponed at least in the context of JMM-related updates.

Among the options is to introduce a @Finalized annotation
for a field of an object. Front-end compilers would
then insert reachabilityFence() after each use. Not necessarily
immediately after though. Optimal placement is non-trivial, which
is one reason this wasn't widely agreed on. It would be great
if some IDE's tried out this kind of support inside IDEs though.

See discussions on jmm-dev list mostly in August 2014.
   http://mail.openjdk.java.net/pipermail/jmm-dev/

(Also, someday, the JLS probably should be updated to explicitly
mention impact of reachabilityFence. The wording change
would basically be the same as the method spec, but a few other
clarifications done at the same time might be helpful.

-Doug




More information about the Concurrency-interest mailing list