RFR: 8354724: BufferedReader readAllLines and readString methods [v14]
Stuart Marks
smarks at openjdk.org
Thu May 1 18:03:51 UTC 2025
On Wed, 23 Apr 2025 22:04:25 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Implement the requested methods and add a test thereof.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> 8354724: Fix readAllChars gaffe in Reader returned by Readed.of and account for it in test
src/java.base/share/classes/java/io/BufferedReader.java line 413:
> 411: * <p> This method works as if invoking it were equivalent to evaluating
> 412: * the expression:
> 413: * <blockquote>{@linkplain #lines()}.toList()</blockquote>
I'd suggest avoiding being too specific here, as this implies that this method will invoke the `lines()` method which can be overridden by a subclass. One could have an argument about whether this indeed is implied by the "as if" wording but I think it would be preferable to avoid this. I also think we don't want to have this method depend on possible overridden methods, so that we can provide a future optimized implementation without breaking something. Thus I think most of this doc comment can be inherited form Reader, even though the implementation might be overridden.
src/java.base/share/classes/java/io/BufferedReader.java line 433:
> 431: public List<String> readAllLines() throws IOException {
> 432: try {
> 433: return lines().toList();
I'd suggest not having this method's implementation depend on an overridable method.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2070590867
PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2070591288
More information about the core-libs-dev
mailing list