RFR 9: 8165641 : Deprecate Object.finalize

Andrew Haley aph at redhat.com
Sun Mar 12 10:07:35 UTC 2017

On 11/03/17 18:56, Hans Boehm 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 would have thought the most significant problem with finalizers is
that finalizers may never run unless the application runs out of
memory.  In practice, this means that finalizers (and
PhantomReferences, Cleaners, and anything else where cleanup is based
on reachability) can't be used to manage scarce resources.  Given that
this is a primary use case for finalizers, I think we're done.

> 3) Some less significant issues, like runFinalization()
> synchronization, difficulty in properly triggering GC for non-memory
> resource exhaustion, slow and deadlocked finalizers, inability to
> finalize more than once, potential need for finalizer guardians,
> etc.

I guess "difficulty in properly triggering GC for non-memory resource
exhaustion" is closest to what I just described.

> Although I agree we'd be marginally better off without finalizers,
> it's unclear to me the improvement is substantial enough to bother
> without more of a replacement story.

I can't disagree with that.  But I welcome this move as an opening


More information about the core-libs-dev mailing list