On Wed, 9 Apr 2025 17:02:52 GMT, Stuart Marks <sma...@openjdk.org> wrote:
>> The readln methods handle malformed-input and unmappable-character errors by >> dropping, and using a replacement value. So erroneous input doesn't throw >> IOError with a CharacterCodingException as the cause. >> >> System.in.close() would a be wild thing to do, but a case where readln would >> throw IOError. > > Ah. Does the specification here need to state the policy around malformed > input and unmappable characters? (Or, maybe in the class specification.) > > People have ended up in cases where System.in is closed. It can occur when > combining use of Scanner to read from System.in and applying the > anything-that-you-open-must-be-closed rule, e.g., > > try (Scanner sc = new Scanner(System.in)) { > String s = sc.nextLine(); > } > > which is a mistake, but it takes a long time to explain.... I added a clause to the class specification that covers malformed/unmappable byte sequences. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24438#discussion_r2036340667