[jmm-dev] Non-core-model issues status
Doug Lea
dl at cs.oswego.edu
Tue Sep 9 11:26:07 UTC 2014
On 09/07/2014 01:55 AM, Hans Boehm wrote:
> we seem to have lots of evidence that essentially everyone currently gets
> this code wrong, introducing premature deallocations.
Continuing in vacillation mode.... What do you think of
the following concrete version of Jeremy's original
suggestion:
1. Introduce reachabilityFence (or whatever name;
How about "keepReachable"?)
2. Spec at syntax level that every declaration and
use of a local (or param) ref to an object of a class F
defining finalize() is translated from:
F f;
...
<end of scope>
to:
F f;
try {
...
<end of scope>
} finally
if (f != null) reachabilityFence(f);
}
It might be a little challenging to spec this to cover multiple
refs while keeping blocked scopes, but it seems feasible.
This seems to completely address premature finalization,
at the expense of lack of control in the other direction.
The only middle ground I see is the one you like least,
of telling people to write their own try-finally blocks.
-Doug
More information about the jmm-dev
mailing list