JDK-8258067 : Clarify java.io.Reader.read(char[], ...) behavior for full array
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.io
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 17
  • Submitted: 2020-12-10
  • Updated: 2020-12-17
  • Resolved: 2020-12-17
Related Reports
CSR :  
Description
Summary
-------

Add verbiage making explicit the behavior of the `Reader` methods read(char[] cbuf) when cbuf.length is zero and read(char[] cbuf, int off, int len) when len is zero.

Problem
-------

The behaviors of read(char[] cbuf) when cbuf.length is zero and read(char[] cbuf, int off, int len) when len is zero are not as completely specified as in the analogous `InputStream` methods.

Solution
--------

Add verbiage making explicit the behavior of the `Reader` methods read(char[] cbuf) when cbuf.length is zero and read(char[] cbuf, int off, int len) when len is zero.

Specification
-------------

To the specification of `Reader::read(char[])` add the paragraph

```If the length of cbuf is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.```

and to that of `Reader::read(char[],int,int)` add the paragraph

``` If len is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.```


Comments
Moving to Approved.
17-12-2020