On Wed, 14 May 2025 17:39:05 GMT, Brian Burkhalter <b...@openjdk.org> wrote:
>> I think `read(str)` is to be preferred over `read(str, 0, str.length()` as >> it allows implementations to provide optimized implementations. What the >> caller of the new methods wants to achieve is getting everything in the best >> possible way, which is, in the most optimized way. If we go around >> high-level methods, we should have a good reason for! > > All other self-calls to a `read` method are to the three-arg abstract method: > > $ grep read( src/java.base/share/classes/java/io/Reader.java | grep -v public > | grep -v * > nread = this.read(cbuf, off, rem); > nread = read(cbuf, 0, len); > if (read(cb, 0, 1) == -1) > return read(cbuf, 0, cbuf.length); > while ((nread = read(cbuf, 0, cbuf.length)) != -1) { > int nc = read(skipBuffer, 0, (int)Math.min(r, nn)); > while ((nRead = read(buffer, 0, TRANSFER_BUFFER_SIZE)) >= 0) { > so that all concrete implementations in this class call only the abstract > three-arg read() method Done in 3cbaede and also `str` -> `cbuf`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2089436030