-
CSR
-
Resolution: Approved
-
P3
-
None
-
source, behavioral
-
low
-
-
Java API
-
SE
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 theclose
method. The recommendation has been to explicitly callclose
or use try-with-resources to close files. With this change the ZipFileclose
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 {}
- csr of
-
JDK-8212129 Remove Finalize methods from ZipFile, Inflater and Deflater
-
- Resolved
-