On Wed, 14 May 2025 17:40:53 GMT, Brian Burkhalter <[email protected]> wrote:
>> 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`.
The code should use the three-arg read() call in order to limit self-calls, in
order to avoid the fragile base class problem. At some point we might want to
add implSpec tags to specify this. See my previous comments relate to this
topic:
https://github.com/openjdk/jdk/pull/24728#issuecomment-2848332415
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2089439008