JDK-8212198 : Remove Finalize methods from ZipFile, Inflater and Deflater
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 12
  • Submitted: 2018-10-15
  • Updated: 2018-11-02
  • Resolved: 2018-10-17
Related Reports
CSR :  
Description
Summary
-------

Remove Finalize methods from ZipFile, Inflater and Deflater

Problem
-------

The finalize methods of ZipFile, Inflater and Deflater were deprecated for removal in JDK 9 and should be removed.

Solution
--------

The `finalize` methods will be removed from ZipFile, Deflator, and Inflator.  As of JDK 9,  these methods are no-ops.

Prior to JDK 9:

 - `ZipFile::finalize` would call the `close` method. The recommendation
   has been to explicitly call `close` or use try-with-resources to
   close files. With this change the ZipFile `close` method will no
   longer be called when a ZipFile is found to be unreachable.
   
 - The Inflator::finalize and Deflator::finalize  methods would call
   the end method. The recommended cleanup for a compressor is to
   explicitly call then end method when it is no longer in use.  If the end
   is not invoked explicitly the resource of the compressor will be
   released when the instance becomes unreachable.

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


**java.util.zip.ZipFile**

**Remove the Implementation Note:**

If this ZipFile has been subclassed and the close method has been overridden, the close method will be called by the finalization when ZipFile is unreachable. But the subclasses should not depend on this specific implementation; the finalization is not reliable and the finalize method is deprecated to be removed.


 
**and removes the method:**

```
protected void finalize() throws IOException {}
```

**java.util.zip.Deflater:**

**Remove the Implementation Note:**

If this Deflater has been subclassed and the end method has been overridden, the end method will be called by the finalization when the deflater is unreachable. But the subclasses should not depend on this specific implementation; the finalization is not reliable and the finalize method is deprecated to be removed.

 **and removes the method:**

```
protected void finalize() throws IOException {}
```

**java.util.zip.Inflater:**

**Remove the Implementation Note:**

If this Inflater has been subclassed and the end method has been overridden, the end method will be called by the finalization when the inflater is unreachable. But the subclasses should not depend on this specific implementation; the finalization is not reliable and the finalize method is deprecated to be removed.

 **and removes the method:**

```
protected void finalize() throws IOException {}
```
Comments
Moving to Approved.
17-10-2018

Moving to Provisional; please create a release note for the parent issue before finalizing.
17-10-2018