JDK-8254808 : Deprecate for removal an empty finalize() methods in java.desktop module
  • Type: CSR
  • Component: client-libs
  • Sub-Component: 2d
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 16
  • Submitted: 2020-10-15
  • Updated: 2020-10-17
  • Resolved: 2020-10-17
Related Reports
CSR :  
Description
Summary
-------

Deprecate for removal empty finalize() methods in the java.desktop module previously deprecated in JDK 9 under JDK-8165641.

Problem
-------

The java.desktop module has a few implementations of the finalize() method which do nothing. We can mark these methods as "forRemoval = true".

Solution
--------

The solution is to deprecate this API in jdk16 and remove it later.

Specification
-------------

    src/java.desktop/share/classes/java/awt/color/ICC_Profile.java
    
    @@ -757,11 +757,12 @@
           *         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")
    +     @Deprecated(since = "9", forRemoval = true)
    +     @SuppressWarnings("removal")
          protected void finalize () {
          }
    
    src/java.desktop/share/classes/java/awt/image/ColorModel.java
    
    @@ -1628,11 +1628,12 @@
           *     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")
    +     @Deprecated(since = "9", forRemoval = true)
    +     @SuppressWarnings("removal")
          public void finalize() {
          }
    
    
    src/java.desktop/share/classes/java/awt/image/IndexColorModel.java
    
    @@ -1522,11 +1522,12 @@
           *     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")
    +     @Deprecated(since = "9", forRemoval = true)
    +     @SuppressWarnings("removal")
          public void finalize() {
          }

  


Comments
Thanks for confirming [~rriggs]; moving to Approved.
17-10-2020

The behavior of the finalize methods was remediated at the time the methods were deprecated.
16-10-2020

Here is an example for the Zip API: - In https://bugs.openjdk.java.net/browse/JDK-8185582 the classes were reimplemented using cleaners and the finalize() were marked as "forRemoval=true": http://hg.openjdk.java.net/jdk/jdk/rev/9f225d4387e2 - Then later the finalize() was removed in https://bugs.openjdk.java.net/browse/JDK-8212129: http://hg.openjdk.java.net/jdk/jdk/rev/52a97e06a5e3
16-10-2020

[~darcy] I am not sure that the cleaners are related to this particular change, the methods mentioned in this fix are all empty/noop. We do not need to reimplement something using cleaners.
16-10-2020

Moving to Provisional, not Approved. Please check with [~rriggs] on what steps were taken in core libs in terms of transitioning to cleaners, etc.
16-10-2020