From b97fc934373d6fd515c70b2b7fde32fe63437597 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Wed, 16 Nov 2022 17:33:14 +0000 Subject: [PATCH] 7132279: (ch) SeekableByteChannel operation may throw Non{Readable,Writable}ChannelException Reviewed-by: lancea, jpai --- .../classes/java/nio/channels/FileChannel.java | 15 ++++++--------- .../java/nio/channels/SeekableByteChannel.java | 2 ++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/java.base/share/classes/java/nio/channels/FileChannel.java b/src/java.base/share/classes/java/nio/channels/FileChannel.java index 9787a87f4f1..b4a4a195023 100644 --- a/src/java.base/share/classes/java/nio/channels/FileChannel.java +++ b/src/java.base/share/classes/java/nio/channels/FileChannel.java @@ -380,6 +380,7 @@ public abstract class FileChannel * @throws ClosedChannelException {@inheritDoc} * @throws AsynchronousCloseException {@inheritDoc} * @throws ClosedByInterruptException {@inheritDoc} + * @throws NonReadableChannelException {@inheritDoc} */ public abstract int read(ByteBuffer dst) throws IOException; @@ -395,6 +396,7 @@ public abstract class FileChannel * @throws ClosedChannelException {@inheritDoc} * @throws AsynchronousCloseException {@inheritDoc} * @throws ClosedByInterruptException {@inheritDoc} + * @throws NonReadableChannelException {@inheritDoc} */ public abstract long read(ByteBuffer[] dsts, int offset, int length) throws IOException; @@ -410,6 +412,7 @@ public abstract class FileChannel * @throws ClosedChannelException {@inheritDoc} * @throws AsynchronousCloseException {@inheritDoc} * @throws ClosedByInterruptException {@inheritDoc} + * @throws NonReadableChannelException {@inheritDoc} */ public final long read(ByteBuffer[] dsts) throws IOException { return read(dsts, 0, dsts.length); @@ -426,12 +429,10 @@ public abstract class FileChannel * behaves exactly as specified by the {@link WritableByteChannel} * interface.

* - * @throws NonWritableChannelException - * If this channel was not opened for writing - * * @throws ClosedChannelException {@inheritDoc} * @throws AsynchronousCloseException {@inheritDoc} * @throws ClosedByInterruptException {@inheritDoc} + * @throws NonWritableChannelException {@inheritDoc} */ public abstract int write(ByteBuffer src) throws IOException; @@ -447,12 +448,10 @@ public abstract class FileChannel * behaves exactly as specified in the {@link GatheringByteChannel} * interface.

* - * @throws NonWritableChannelException - * If this channel was not opened for writing - * * @throws ClosedChannelException {@inheritDoc} * @throws AsynchronousCloseException {@inheritDoc} * @throws ClosedByInterruptException {@inheritDoc} + * @throws NonWritableChannelException {@inheritDoc} */ public abstract long write(ByteBuffer[] srcs, int offset, int length) throws IOException; @@ -468,12 +467,10 @@ public abstract class FileChannel * behaves exactly as specified in the {@link GatheringByteChannel} * interface.

* - * @throws NonWritableChannelException - * If this channel was not opened for writing - * * @throws ClosedChannelException {@inheritDoc} * @throws AsynchronousCloseException {@inheritDoc} * @throws ClosedByInterruptException {@inheritDoc} + * @throws NonWritableChannelException {@inheritDoc} */ public final long write(ByteBuffer[] srcs) throws IOException { return write(srcs, 0, srcs.length); diff --git a/src/java.base/share/classes/java/nio/channels/SeekableByteChannel.java b/src/java.base/share/classes/java/nio/channels/SeekableByteChannel.java index b75b9a5f949..e457125b5d3 100644 --- a/src/java.base/share/classes/java/nio/channels/SeekableByteChannel.java +++ b/src/java.base/share/classes/java/nio/channels/SeekableByteChannel.java @@ -64,6 +64,7 @@ public interface SeekableByteChannel * @throws ClosedChannelException {@inheritDoc} * @throws AsynchronousCloseException {@inheritDoc} * @throws ClosedByInterruptException {@inheritDoc} + * @throws NonReadableChannelException {@inheritDoc} */ @Override int read(ByteBuffer dst) throws IOException; @@ -83,6 +84,7 @@ public interface SeekableByteChannel * @throws ClosedChannelException {@inheritDoc} * @throws AsynchronousCloseException {@inheritDoc} * @throws ClosedByInterruptException {@inheritDoc} + * @throws NonWritableChannelException {@inheritDoc} */ @Override int write(ByteBuffer src) throws IOException;