RFR 9: 8165641 : Deprecate Object.finalize

Hans Boehm hboehm at google.com
Mon Mar 13 20:55:50 UTC 2017

I agree that's also an issue. But it's clearly fixable with smallish API
additions. It's less important in my context, since more than 90% of
finalizers I see are for Java wrappers of native objects, where it actually
seems to be mildly painful to have to keep the associated reference live.

On Mon, Mar 13, 2017 at 12:25 PM, Kim Barrett <kim.barrett at oracle.com>

> > On Mar 11, 2017, at 1:56 PM, Hans Boehm <hboehm at google.com> wrote:
> > Stepping back, I'm a little surprised at the deprecation. In my opinion,
> > the problems with finalizers are, in rough order of significance:
> I think an important difference between finalize and other
> j.l.r.Reference-based cleanups that hasn't been mentioned is that
> finalization is not cancellable. If one creates creates a finalizable
> object and explicitly "closes" it when done with it, there is no way
> to avoid the later finalization processing that will ultimately be a
> very expensive nop.  For an example of this problem, see
> https://issues.apache.org/jira/browse/HDFS-8562
> Extending finalization as suggested there seems to me to be feature
> creep on a facility that we already heavily denigrate and would prefer
> didn't exist.

More information about the core-libs-dev mailing list