JDK-8273103 : Delete deprecated for removal the empty finalize() in java.desktop module
  • Type: CSR
  • Component: client-libs
  • Sub-Component: 2d
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 18
  • Submitted: 2021-08-29
  • Updated: 2022-01-31
  • Resolved: 2021-09-18
Related Reports
CSR :  
Description
Summary
-------

The "java.desktop" module has a few implementations of the finalize() which do nothing, deprecated since Java 9, and are marked "forRemoval = true" since Java 16. 

Solution
--------

Delete three "finalize()" methods.

Specification
-------------
    src/java.desktop/share/classes/java/awt/color/ICC_Profile.java
     
    -    /**
    -     * Frees the resources associated with an {@code ICC_Profile} object.
    -     *
    -     * @deprecated The {@code finalize} method has been deprecated. Subclasses
    -     *         that override {@code finalize} in order to perform cleanup should
    -     *         be modified to use alternative cleanup mechanisms and to remove
    -     *         the overriding {@code finalize} method. When overriding the
    -     *         {@code finalize} method, its implementation must explicitly
    -     *         ensure that {@code super.finalize()} is invoked as described in
    -     *         {@link Object#finalize}. See the specification for {@link
    -     *         Object#finalize()} for further information about migration
    -     *         options.
    -     */
    -    @Deprecated(since = "9", forRemoval = true)
    -    @SuppressWarnings("removal")
    -    protected void finalize() {
    -    }


    src/java.desktop/share/classes/java/awt/image/ColorModel.java
    
    -    /**
    -     * Disposes of system resources associated with this
    -     * {@code ColorModel} once this {@code ColorModel} is no
    -     * longer referenced.
    -     *
    -     * @deprecated The {@code finalize} method has been deprecated.
    -     *     Subclasses that override {@code finalize} in order to perform cleanup
    -     *     should be modified to use alternative cleanup mechanisms and
    -     *     to remove the overriding {@code finalize} method.
    -     *     When overriding the {@code finalize} method, its implementation must explicitly
    -     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
    -     *     See the specification for {@link Object#finalize()} for further
    -     *     information about migration options.
    -     */
    -    @Deprecated(since = "9", forRemoval = true)
    -    @SuppressWarnings("removal")
    -    public void finalize() {
    -    }


    src/java.desktop/share/classes/java/awt/image/IndexColorModel.java

    -    /**
    -     * Disposes of system resources associated with this
    -     * {@code ColorModel} once this {@code ColorModel} is no
    -     * longer referenced.
    -     *
    -     * @deprecated The {@code finalize} method has been deprecated.
    -     *     Subclasses that override {@code finalize} in order to perform cleanup
    -     *     should be modified to use alternative cleanup mechanisms and
    -     *     to remove the overriding {@code finalize} method.
    -     *     When overriding the {@code finalize} method, its implementation must explicitly
    -     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
    -     *     See the specification for {@link Object#finalize()} for further
    -     *     information about migration options.
    -     */
    -    @Deprecated(since = "9", forRemoval = true)
    -    @SuppressWarnings("removal")
    -    public void finalize() {
    -    }

Link for convenience:
https://github.com/openjdk/jdk/pull/5292/files

Comments
Moving to Approved contingent on a release note being written.
18-09-2021

> Two of the three removed methods are public, which would impact an application calling those methods. Yes, so minimal compat risk was optimistic. I've updated it to low which is I think fairer. As to the release note, I am not sure this meets the bar for that, but if the consensus is otherwise I won't object.
12-09-2021

Two of the three removed methods are public, which would impact an application calling those methods.
10-09-2021

Removing a class' protected finalize method should be a no-op. Subclasses that call super.finalize() will be calling Object.finalize(). A release note would reinforce the idea that we are acting on removing finalize, and could be a opportunity to call for developers to do the same. But there isn't any change in behavior that might cause a problem for existing classes. Any finalize methods already removed would have been private or have been left empty when the behavior was moved to use the Cleaner.
10-09-2021

Moving to Provisional, not Approved. [~rriggs], how does this compare to any other finalize method that have been removed after JDK-8165641? My sense is a release note should be written for this change, especially if it is one of the first cases of finalize methods being removed.
10-09-2021

Looks good to me.
31-08-2021