On Mon, 23 Jun 2025 21:23:05 GMT, Stuart Marks <sma...@openjdk.org> wrote:
>> src/java.base/share/classes/java/io/Reader.java line 508: >> >>> 506: } >>> 507: >>> 508: return lines; >> >> Do we really want to return a mutable `ArrayList` here? In earlier >> discussions about this very API I was told that it deliberately returns >> `String` instead of `CharSequence` due to *intended* immutability, even if >> that potentially implied slower performance. Following this logic, it would >> be just straightforward to `return Collections.unmodifiableList(lines);` >> here. 🤔 > > Right, the specification here requires an unmodifiable List, so an > unmodifiable wrapper or a list from `List.copyOf()` is appropriate. Fixed in [d5abfa4](https://github.com/openjdk/jdk/pull/25863/commits/d5abfa450cb3fcd604560833038735e41952bce9 ). ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25863#discussion_r2164687743