8305762: FileInputStream and FileOutputStream implSpec should be corrected or removed

Reviewed-by: kbarrett, alanb, bpb
This commit is contained in:
Brent Christian 2023-04-17 20:40:47 +00:00
parent 8858d54342
commit bb1a7bb3e1
2 changed files with 18 additions and 30 deletions

View File

@ -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}
*

View File

@ -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.
*