RFR 9: 8165641 : Deprecate Object.finalize

Hans Boehm hboehm at google.com
Fri Mar 31 17:05:57 UTC 2017

In my view, the primary reason to prefer Cleaner or PhantomReference is
safety (no accidental access to previously finalized objects, which usually
turn into dangling pointer dereferences with JNI). Flexibility and
efficiency also matter, but I would put them second and third.

Can we add a warning that it is almost never safe to override finalize()
without use of reachabilityFence()?

On Fri, Mar 31, 2017 at 6:55 AM, Roger Riggs <Roger.Riggs at oracle.com> wrote:

> The webrev for deprecating finalize has been updated:
>  - to improve the advice existing JDK subclasses overriding finalize
> provides in @deprecated javadoc,
>  - to expand Object.finalize() javadoc to reinforce the correct use of
> super.finalize() by subclasses,
>  - and to remove redundant @SuppressWarnings annotations.
> Please review and comment.
> Webrev:
> http://cr.openjdk.java.net/~rriggs/webrev-finalize-deprecate-8165641/
> Issue:
>    https://bugs.openjdk.java.net/browse/JDK-8165641
> Thanks, Roger

More information about the core-libs-dev mailing list