RFR: 8354724: BufferedReader readAllLines and readString methods [v14]

Brian Burkhalter bpb at openjdk.org
Mon May 5 20:45:50 UTC 2025


On Thu, 1 May 2025 18:00:54 GMT, Stuart Marks <smarks at openjdk.org> wrote:

> I'd suggest not having this method's implementation depend on an overridable method.

I'm jumping the gun here by referring to an implementation detail, but the overridable method problem could be circumvented using an approach taken in other classes in `java.io`:

        if (getClass() == BufferedReader.class) {
            try {
                return lines().toList();
            } catch (UncheckedIOException ue) {
                // the cause cannot be null
                throw ue.getCause();
            }
        } else {
            return super.readAllLines();
        }

This would not need to be mentioned in the specification.

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

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


More information about the core-libs-dev mailing list