RFR: 8354724: Methods in java.io.Reader to read all characters and all lines [v22]

Markus KARG duke at openjdk.org
Wed May 14 21:05:06 UTC 2025


On Wed, 14 May 2025 20:58:47 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> BTW, paraphrasing Stuart here: "We want to reduce self-calls". `subSequence` is a self-call, *as we do not know* how it behaves in the actual implementation. For `getChars` we can be sure that it has no overridable side effects.
>
> Both `subSequence` and `getChars` are implemented by the CharSequence.
> They have the same level of trustworthiness about their implementation.

I meant that the implementation of `subSequence` *might or might not* perform copy (so we need to tell the javaDoc reader), while `getChar` *clearly* performs a copy as part of it design. So `subSequence` can be surprising as this discussion proofs, while `getChars` will not. That was Stuart's point with `read`, and that was your point with `CharSequence`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2089749078


More information about the core-libs-dev mailing list