RFR: 8247918: Clarify Reader.skip behavior for end of stream

Brian Burkhalter bpb at openjdk.java.net
Mon Feb 8 23:00:58 UTC 2021


On Mon, 8 Feb 2021 22:51:43 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> Please review this clarification of the specification of the method `skip(long)` in `java.io.Reader` and its subclasses. Specifically, the behavior of the method is made clear for the case when the `Reader` is already at the end of its stream when the method is invoked. A corresponding CSR will be filed. Also, the change includes an update to an existing test in order to verify that the specification change reflects actual behavior.
>
> src/java.base/share/classes/java/io/FilterReader.java line 81:
> 
>> 79:      * {@inheritDoc}
>> 80:      *
>> 81:      * @throws     IllegalArgumentException  If {@code n} is negative and the
> 
> Does this have to be different from the `Reader.skip()`'s description? Since the contained reader implements `Reader` (throws IAE as a contract), that condition after `and` is always true?

This came from some `Reader`s, e.g., `CharArrayReader`, `StringReader`, overriding `skip()` _not_ to throw an IAE. But at the specification level perhaps this should not be recognized.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2274


More information about the core-libs-dev mailing list