JDK-8212050 : Remove Finalize methods from FileInputStream and FileOutputStream
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.io
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 12
  • Submitted: 2018-10-11
  • Updated: 2018-10-16
  • Resolved: 2018-10-16
Related Reports
CSR :  
Relates :  
Description
Summary
-------

Remove the deprecated finalize methods of FileInputStream and FIleOutputStream. 

Problem
-------

The `finalize` methods of FileInputStream and FileOutputStream were deprecated for removal in JDK 9 and should be removed.

Solution
--------

The `finalize` methods are removed.

The `java.lang.ref.Cleaner` has been implemented since JDK 9 as the primary mechanism to close FileDescriptors no longer reachable from FileInputStream and FileOutputStreams.

Previously, `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 FileInputStream or FileOutputStream `close` method will no longer be called when a FileInputstream or FileOutputStream is found to be unreachable. 

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

java.io.FileInputStream removes:

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

java.io.FileOutputStream removes:

```
protected void finalize() throws IOException {}
```
Comments
Voting to Approve. I see a release note is already planned for the parent issue.
16-10-2018