[jmm-dev] finalization

Doug Lea dl at cs.oswego.edu
Fri Aug 15 15:19:13 UTC 2014


On 08/14/2014 09:38 PM, Hans Boehm wrote:
>
> On Thu, Aug 14, 2014 at 5:22 PM, Doug Lea <dl at cs.oswego.edu
>
>     I'm suggesting something slightly simpler. A reachabilityFence(x)
>     is placed/checked after each access of @Finalized field x.r.
>     No other JLS changes.
>
> I don't think that keeping it live until just after the access is good enough.

Right; "after" doesn't necessarily mean "immediately following the
resource field access bytecode", which would usually not be helpful.
Even placing at end of current source-level block might not be
conservative enough:
  Resource s; {  Resource r = this.resource; s = r; } use(s) ...

Short of requiring full dataflow analysis tracing all dependencies of the
resource field read, the safest and probably easiest policy seems to be
to insert upon method exit. But in some cases this would retain
enough garbage that some programmers would want to manually override.

These (and others I've mentioned) are the sorts of issues I had in mind
in my initial "don't play if you can't win" reaction.

I think we all agree that we must minimally introduce
reachabilityFence(ref), and modify JLS 12.6.2 accordingly.

Beyond that, introducing and defining the effects of @Finalized
seems plausible, although still short of compelling because of
limitations and the looseness of @Finalized specs that they imply.
So any tools developed to insert or check reachabilityFences
will need to provide enough details to be useful to programmers.
Which suggests ceding the entire territory to tool developers.

And I still don't see a compelling argument for any other
automatic scope-widening approach.

-Doug



More information about the jmm-dev mailing list