diff --git a/src/java.base/share/classes/java/io/FileInputStream.java b/src/java.base/share/classes/java/io/FileInputStream.java index e882946cf74..a1797cf1246 100644 --- a/src/java.base/share/classes/java/io/FileInputStream.java +++ b/src/java.base/share/classes/java/io/FileInputStream.java @@ -41,19 +41,13 @@ import sun.nio.ch.FileChannelImpl; * {@code FileReader}. * * @apiNote - * To release resources used by this stream {@link #close} should be called - * directly or by try-with-resources. Subclasses are responsible for the cleanup - * of resources acquired by the subclass. - * Subclasses that override {@link #finalize} in order to perform cleanup - * should be modified to use alternative cleanup mechanisms such as - * {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method. + * The {@link #close} method should be called to release resources used by this + * stream, either directly, or with the {@code try}-with-resources statement. * * @implSpec - * If this FileInputStream has been subclassed and the {@link #close} - * method has been overridden, the {@link #close} method will be - * called when the FileInputStream is unreachable. - * Otherwise, it is implementation specific how the resource cleanup described in - * {@link #close} is performed. + * Subclasses are responsible for the cleanup of resources acquired by the subclass. + * Subclasses requiring that resource cleanup take place after a stream becomes + * unreachable should use {@link java.lang.ref.Cleaner} or some other mechanism. * * @author Arthur van Hoff * @see java.io.File @@ -494,10 +488,10 @@ public class FileInputStream extends InputStream * @apiNote * Overriding {@link #close} to perform cleanup actions is reliable * only when called directly or when called by try-with-resources. - * Do not depend on finalization to invoke {@code close}; - * finalization is not reliable and is deprecated. - * If cleanup of native resources is needed, other mechanisms such as - * {@linkplain java.lang.ref.Cleaner} should be used. + * + * @implSpec + * Subclasses requiring that resource cleanup take place after a stream becomes + * unreachable should use the {@link java.lang.ref.Cleaner} mechanism. * * @throws IOException {@inheritDoc} * diff --git a/src/java.base/share/classes/java/io/FileOutputStream.java b/src/java.base/share/classes/java/io/FileOutputStream.java index 5d2dead569a..9aadf1f38be 100644 --- a/src/java.base/share/classes/java/io/FileOutputStream.java +++ b/src/java.base/share/classes/java/io/FileOutputStream.java @@ -46,19 +46,13 @@ import sun.nio.ch.FileChannelImpl; * {@code FileWriter}. * * @apiNote - * To release resources used by this stream {@link #close} should be called - * directly or by try-with-resources. Subclasses are responsible for the cleanup - * of resources acquired by the subclass. - * Subclasses that override {@link #finalize} in order to perform cleanup - * should be modified to use alternative cleanup mechanisms such as - * {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method. + * The {@link #close} method should be called to release resources used by this + * stream, either directly, or with the {@code try}-with-resources statement. * * @implSpec - * If this FileOutputStream has been subclassed and the {@link #close} - * method has been overridden, the {@link #close} method will be - * called when the FileInputStream is unreachable. - * Otherwise, it is implementation specific how the resource cleanup described in - * {@link #close} is performed. + * Subclasses are responsible for the cleanup of resources acquired by the subclass. + * Subclasses requiring that resource cleanup take place after a stream becomes + * unreachable should use {@link java.lang.ref.Cleaner} or some other mechanism. * * @author Arthur van Hoff * @see java.io.File @@ -387,10 +381,10 @@ public class FileOutputStream extends OutputStream * @apiNote * Overriding {@link #close} to perform cleanup actions is reliable * only when called directly or when called by try-with-resources. - * Do not depend on finalization to invoke {@code close}; - * finalization is not reliable and is deprecated. - * If cleanup of native resources is needed, other mechanisms such as - * {@linkplain java.lang.ref.Cleaner} should be used. + * + * @implSpec + * Subclasses requiring that resource cleanup take place after a stream becomes + * unreachable should use the {@link java.lang.ref.Cleaner} mechanism. * * @throws IOException if an I/O error occurs. *