RFR 9: 8165641 : Deprecate Object.finalize

Hans Boehm hboehm at google.com
Sat Apr 1 17:19:05 UTC 2017


That also sounds fine to me.

The difficulty with applying this, especially in the JNI case, is that you
may need several reachability fences at the end of each method, guarding
parameters and temporaries, not all of which may be naturally in scope at
the end. But we're not going to be able to include a full discussion here.

In the interest of full disclosure, we currently, at least temporarily,
dodge this issue by inhibiting dead variable elimination for references.


On Apr 1, 2017 01:55, "Andrew Haley" <aph at redhat.com> wrote:

On 31/03/17 19:56, Hans Boehm wrote:
> This method should be used when cleanup actions (finalize() calls, or
> Reference enqueuing, Cleaner invocation) could otherwise be triggered
while
> a resource under control of the object is still in use. This method should
> normally be called when these cleanup facilities are used to perform
> actions other than simply issuing a warning.

It's still pretty confusing.  It would be simpler to say that
reachabilityFence should be used at the end of every method of a class
which has cleanup actions if you don't want those cleanup actions to
be run before the end of that method.  In that case, reachabilityFence
only makes any difference in cases where otherwise you'd have a bug.

Andrew.


More information about the core-libs-dev mailing list