RFR: 8354724: Methods in java.io.Reader to read all characters and all lines [v19]
Markus KARG
duke at openjdk.org
Wed May 14 17:59:55 UTC 2025
On Wed, 14 May 2025 17:42:33 GMT, Stuart Marks <smarks at openjdk.org> wrote:
>>> 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
I know that comment already, but IMHO we can simply use `@implSpec` to unambiguously make clear that this method invokes `read(char[])` to allow optimized implementations, and it *might* in turn invoke `read(char[],int,int)`, but this is *not guaranteed*. A class is only fragile as long as we do not *document* what it will do.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2089456975
More information about the core-libs-dev
mailing list