From acobbs at openjdk.org Thu Oct 3 22:37:04 2024 From: acobbs at openjdk.org (Archie Cobbs) Date: Thu, 3 Oct 2024 22:37:04 GMT Subject: RFR: 8341495: JShell crashes with java.util.MissingFormatArgumentException Message-ID: JShell prints some of its output using `printf()` formatted strings. However, there are a few spots where a string `str` to be printed is passed directly as a format string like `format(str)` instead of indirectly like `format("%s", str)`, even though the string `str` contains unknown or arbitrary content outside of JShell's control. As a result, JShell can crash suddenly with a `MissingFormatArgumentException` or similar exception if the string `str` happens to contain a `%` format specifier, etc. Please review this patch which attempts to fix the places where an unknown string is passed directly as a format string. ------------- Commit messages: - Avoid invoking out.printf() with unknown format strings that might contain escapes. Changes: https://git.openjdk.org/jdk/pull/21339/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21339&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8341495 Stats: 58 lines in 2 files changed: 53 ins; 0 del; 5 mod Patch: https://git.openjdk.org/jdk/pull/21339.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/21339/head:pull/21339 PR: https://git.openjdk.org/jdk/pull/21339 From acobbs at openjdk.org Fri Oct 4 02:27:16 2024 From: acobbs at openjdk.org (Archie Cobbs) Date: Fri, 4 Oct 2024 02:27:16 GMT Subject: RFR: 8341495: JShell crashes with java.util.MissingFormatArgumentException [v2] In-Reply-To: References: Message-ID: > JShell prints some of its output using `printf()` formatted strings. However, there are a few spots where a string `str` to be printed is passed directly as a format string like `format(str)` instead of indirectly like `format("%s", str)`, even though the string `str` contains unknown or arbitrary content outside of JShell's control. As a result, JShell can crash suddenly with a `MissingFormatArgumentException` or similar exception if the string `str` happens to contain a `%` format specifier, etc. > > Please review this patch which attempts to fix the places where an unknown string is passed directly as a format string. Archie Cobbs has updated the pull request incrementally with one additional commit since the last revision: Fix prefixing/postfixing logic broken by previous commit. ------------- Changes: - all: https://git.openjdk.org/jdk/pull/21339/files - new: https://git.openjdk.org/jdk/pull/21339/files/ab1c9b2b..e8116cba Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=21339&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21339&range=00-01 Stats: 34 lines in 6 files changed: 8 ins; 0 del; 26 mod Patch: https://git.openjdk.org/jdk/pull/21339.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/21339/head:pull/21339 PR: https://git.openjdk.org/jdk/pull/21339 From acobbs at openjdk.org Fri Oct 4 15:01:55 2024 From: acobbs at openjdk.org (Archie Cobbs) Date: Fri, 4 Oct 2024 15:01:55 GMT Subject: RFR: 8341495: JShell crashes with java.util.MissingFormatArgumentException [v3] In-Reply-To: References: Message-ID: > JShell prints some of its output using `printf()` formatted strings. However, there are a few spots where a string `str` to be printed is passed directly as a format string like `format(str)` instead of indirectly like `format("%s", str)`, even though the string `str` contains unknown or arbitrary content outside of JShell's control. As a result, JShell can crash suddenly with a `MissingFormatArgumentException` or similar exception if the string `str` happens to contain a `%` format specifier, etc. > > Please review this patch which attempts to fix the places where an unknown string is passed directly as a format string. Archie Cobbs has updated the pull request incrementally with two additional commits since the last revision: - Revert previous change to unrelated JLine prompt substitution. - Use replace() instead of replaceAll() for literal string substitution. ------------- Changes: - all: https://git.openjdk.org/jdk/pull/21339/files - new: https://git.openjdk.org/jdk/pull/21339/files/e8116cba..f8a5de5f Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=21339&range=02 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21339&range=01-02 Stats: 2 lines in 2 files changed: 0 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/21339.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/21339/head:pull/21339 PR: https://git.openjdk.org/jdk/pull/21339 From liach at openjdk.org Fri Oct 4 15:01:55 2024 From: liach at openjdk.org (Chen Liang) Date: Fri, 4 Oct 2024 15:01:55 GMT Subject: RFR: 8341495: JShell crashes with java.util.MissingFormatArgumentException [v2] In-Reply-To: References: Message-ID: On Fri, 4 Oct 2024 02:27:16 GMT, Archie Cobbs wrote: >> JShell prints some of its output using `printf()` formatted strings. However, there are a few spots where a string `str` to be printed is passed directly as a format string like `format(str)` instead of indirectly like `format("%s", str)`, even though the string `str` contains unknown or arbitrary content outside of JShell's control. As a result, JShell can crash suddenly with a `MissingFormatArgumentException` or similar exception if the string `str` happens to contain a `%` format specifier, etc. >> >> Please review this patch which attempts to fix the places where an unknown string is passed directly as a format string. > > Archie Cobbs has updated the pull request incrementally with one additional commit since the last revision: > > Fix prefixing/postfixing logic broken by previous commit. src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java line 839: > 837: * @return the pre/post-fixed and bracketed format string > 838: */ > 839: String prefix(String s, String pre, String post) { Shouldn't this `s` be renamed to `format` too, if you perform such a rename? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21339#discussion_r1787742325 From acobbs at openjdk.org Fri Oct 4 15:08:07 2024 From: acobbs at openjdk.org (Archie Cobbs) Date: Fri, 4 Oct 2024 15:08:07 GMT Subject: RFR: 8341495: JShell crashes with java.util.MissingFormatArgumentException [v4] In-Reply-To: References: Message-ID: > JShell prints some of its output using `printf()` formatted strings. However, there are a few spots where a string `str` to be printed is passed directly as a format string like `format(str)` instead of indirectly like `format("%s", str)`, even though the string `str` contains unknown or arbitrary content outside of JShell's control. As a result, JShell can crash suddenly with a `MissingFormatArgumentException` or similar exception if the string `str` happens to contain a `%` format specifier, etc. > > Please review this patch which attempts to fix the places where an unknown string is passed directly as a format string. Archie Cobbs has updated the pull request incrementally with one additional commit since the last revision: Rename another String parameter to "format" to reflect its purpose. ------------- Changes: - all: https://git.openjdk.org/jdk/pull/21339/files - new: https://git.openjdk.org/jdk/pull/21339/files/f8a5de5f..4e692b45 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=21339&range=03 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21339&range=02-03 Stats: 5 lines in 1 file changed: 0 ins; 0 del; 5 mod Patch: https://git.openjdk.org/jdk/pull/21339.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/21339/head:pull/21339 PR: https://git.openjdk.org/jdk/pull/21339 From acobbs at openjdk.org Fri Oct 4 15:08:07 2024 From: acobbs at openjdk.org (Archie Cobbs) Date: Fri, 4 Oct 2024 15:08:07 GMT Subject: RFR: 8341495: JShell crashes with java.util.MissingFormatArgumentException [v2] In-Reply-To: References: Message-ID: <0zAbqctijnnJWBfHTGl0gB5qWUHwX6h_PqEtim2nRMQ=.0f823c4d-26d3-452c-a6bc-ac5a767d652e@github.com> On Fri, 4 Oct 2024 13:43:58 GMT, Chen Liang wrote: >> Archie Cobbs has updated the pull request incrementally with one additional commit since the last revision: >> >> Fix prefixing/postfixing logic broken by previous commit. > > src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java line 839: > >> 837: * @return the pre/post-fixed and bracketed format string >> 838: */ >> 839: String prefix(String s, String pre, String post) { > > Shouldn't this `s` be renamed to `format` too, if you perform such a rename? Yes, thanks. Fixed in 4e692b457db. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21339#discussion_r1787858825 From jlahoda at openjdk.org Thu Oct 24 19:32:29 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Thu, 24 Oct 2024 19:32:29 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() Message-ID: This PR is simply adding parameter-less `java.io.IO.{println(),readln()}`, with the (hopefully) obvious semantics, plus the corresponding wiring to make those work. This may become part of JEP 495: https://openjdk.org/jeps/495 ------------- Commit messages: - Adding support for IO.readln() - 8342936: Enhance java.io.IO with parameter-less println() Changes: https://git.openjdk.org/jdk/pull/21693/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21693&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8342936 Stats: 214 lines in 13 files changed: 197 ins; 8 del; 9 mod Patch: https://git.openjdk.org/jdk/pull/21693.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/21693/head:pull/21693 PR: https://git.openjdk.org/jdk/pull/21693 From jlahoda at openjdk.org Fri Oct 25 06:56:30 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Fri, 25 Oct 2024 06:56:30 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v2] In-Reply-To: References: Message-ID: <8Hfsbc8W7ItgCmH4P7kSapfiPIym6rAsGslOo_3vg94=.92d5f913-7cb1-4111-be1b-7a8c213e9854@github.com> > This PR is simply adding parameter-less `java.io.IO.{println(),readln()}`, with the (hopefully) obvious semantics, plus the corresponding wiring to make those work. This may become part of JEP 495: > https://openjdk.org/jeps/495 Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision: Removing incorrect sentence about writing a prompt for the prompt-less readln method. ------------- Changes: - all: https://git.openjdk.org/jdk/pull/21693/files - new: https://git.openjdk.org/jdk/pull/21693/files/3554045b..78bf15bf Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=21693&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21693&range=00-01 Stats: 2 lines in 1 file changed: 0 ins; 1 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/21693.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/21693/head:pull/21693 PR: https://git.openjdk.org/jdk/pull/21693 From asotona at openjdk.org Fri Oct 25 09:41:06 2024 From: asotona at openjdk.org (Adam Sotona) Date: Fri, 25 Oct 2024 09:41:06 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v2] In-Reply-To: <8Hfsbc8W7ItgCmH4P7kSapfiPIym6rAsGslOo_3vg94=.92d5f913-7cb1-4111-be1b-7a8c213e9854@github.com> References: <8Hfsbc8W7ItgCmH4P7kSapfiPIym6rAsGslOo_3vg94=.92d5f913-7cb1-4111-be1b-7a8c213e9854@github.com> Message-ID: <5IIzPq2EK4pFsO50nQIGLSRYR3WJ47zbiVTTd5rssPE=.decdca3c-219d-4224-a702-62c9f50e1933@github.com> On Fri, 25 Oct 2024 06:56:30 GMT, Jan Lahoda wrote: >> This PR is simply adding parameter-less `java.io.IO.{println(),readln()}`, with the (hopefully) obvious semantics, plus the corresponding wiring to make those work. This may become part of JEP 495: >> https://openjdk.org/jeps/495 > > Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision: > > Removing incorrect sentence about writing a prompt for the prompt-less readln method. Looks good to me. ------------- Marked as reviewed by asotona (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/21693#pullrequestreview-2394768522 From naoto at openjdk.org Fri Oct 25 16:24:07 2024 From: naoto at openjdk.org (Naoto Sato) Date: Fri, 25 Oct 2024 16:24:07 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v2] In-Reply-To: <8Hfsbc8W7ItgCmH4P7kSapfiPIym6rAsGslOo_3vg94=.92d5f913-7cb1-4111-be1b-7a8c213e9854@github.com> References: <8Hfsbc8W7ItgCmH4P7kSapfiPIym6rAsGslOo_3vg94=.92d5f913-7cb1-4111-be1b-7a8c213e9854@github.com> Message-ID: On Fri, 25 Oct 2024 06:56:30 GMT, Jan Lahoda wrote: >> This PR is simply adding parameter-less `java.io.IO.{println(),readln()}`, with the (hopefully) obvious semantics, plus the corresponding wiring to make those work. This may become part of JEP 495: >> https://openjdk.org/jeps/495 > > Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision: > > Removing incorrect sentence about writing a prompt for the prompt-less readln method. +1 ------------- Marked as reviewed by naoto (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/21693#pullrequestreview-2395793885 From jpai at openjdk.org Sat Oct 26 09:29:04 2024 From: jpai at openjdk.org (Jaikiran Pai) Date: Sat, 26 Oct 2024 09:29:04 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v2] In-Reply-To: <8Hfsbc8W7ItgCmH4P7kSapfiPIym6rAsGslOo_3vg94=.92d5f913-7cb1-4111-be1b-7a8c213e9854@github.com> References: <8Hfsbc8W7ItgCmH4P7kSapfiPIym6rAsGslOo_3vg94=.92d5f913-7cb1-4111-be1b-7a8c213e9854@github.com> Message-ID: On Fri, 25 Oct 2024 06:56:30 GMT, Jan Lahoda wrote: >> This PR is simply adding parameter-less `java.io.IO.{println(),readln()}`, with the (hopefully) obvious semantics, plus the corresponding wiring to make those work. This may become part of JEP 495: >> https://openjdk.org/jeps/495 > > Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision: > > Removing incorrect sentence about writing a prompt for the prompt-less readln method. Hello Jan, the GitHub actions job failures look related: /Users/runner/work/jdk/jdk/test/langtools/jdk/jshell/ConsoleTest.java:229: error: ThrowingJShellConsole is not abstract and does not override abstract method readLine() in JShellConsole private static class ThrowingJShellConsole implements JShellConsole { ^ /Users/runner/work/jdk/jdk/test/langtools/jdk/jshell/ConsoleTest.java:199: error: is not abstract and does not override abstract method readLine() in JShellConsole super.setUp(bc.andThen(b -> b.console(new JShellConsole() { ^ 2 errors result: Failed. Compilation failed: Compilation failed ------------- PR Comment: https://git.openjdk.org/jdk/pull/21693#issuecomment-2439446550 From jlahoda at openjdk.org Tue Oct 29 08:13:22 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Tue, 29 Oct 2024 08:13:22 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v2] In-Reply-To: References: <8Hfsbc8W7ItgCmH4P7kSapfiPIym6rAsGslOo_3vg94=.92d5f913-7cb1-4111-be1b-7a8c213e9854@github.com> Message-ID: <4AM6C06GRFCZDRuuIEC7hZ6pmObVdM6ihV_uR66OUSQ=.80087cc1-d516-4776-a1dd-e721063007d8@github.com> On Sat, 26 Oct 2024 09:26:51 GMT, Jaikiran Pai wrote: > Hello Jan, the GitHub actions job failures look related: Yes, sorry for that. Should be fixed now. ------------- PR Comment: https://git.openjdk.org/jdk/pull/21693#issuecomment-2443519095 From jlahoda at openjdk.org Tue Oct 29 08:13:22 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Tue, 29 Oct 2024 08:13:22 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v3] In-Reply-To: References: Message-ID: > This PR is simply adding parameter-less `java.io.IO.{println(),readln()}`, with the (hopefully) obvious semantics, plus the corresponding wiring to make those work. This may become part of JEP 495: > https://openjdk.org/jeps/495 Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision: Fixing test for Console.readln/readLine, ensuring the proper methods are called. ------------- Changes: - all: https://git.openjdk.org/jdk/pull/21693/files - new: https://git.openjdk.org/jdk/pull/21693/files/78bf15bf..eadbc685 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=21693&range=02 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21693&range=01-02 Stats: 46 lines in 3 files changed: 29 ins; 13 del; 4 mod Patch: https://git.openjdk.org/jdk/pull/21693.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/21693/head:pull/21693 PR: https://git.openjdk.org/jdk/pull/21693 From jpai at openjdk.org Wed Oct 30 08:20:06 2024 From: jpai at openjdk.org (Jaikiran Pai) Date: Wed, 30 Oct 2024 08:20:06 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v3] In-Reply-To: References: Message-ID: On Tue, 29 Oct 2024 08:13:22 GMT, Jan Lahoda wrote: >> This PR is simply adding parameter-less `java.io.IO.{println(),readln()}`, with the (hopefully) obvious semantics, plus the corresponding wiring to make those work. This may become part of JEP 495: >> https://openjdk.org/jeps/495 > > Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision: > > Fixing test for Console.readln/readLine, ensuring the proper methods are called. src/java.base/share/classes/java/io/Console.java line 184: > 182: */ > 183: @PreviewFeature(feature = PreviewFeature.Feature.IMPLICIT_CLASSES) > 184: public Console println() { Hello Jan, with the introduction of the simplified `java.io.IO` class, some of whose APIs are wrappers around the `java.io.Console` class APIs, it's understandable that we will start seeing new methods being introduced on the `Console` class. For this specific new `println()` method on the `Console` class, do you think this method will/should be introduced irrespective of the `IO` class usage? In other words, considering a theoretic case where there may be a situation to abandon the implicit classes preview feature or do it in a different way, would we still want this `println()` method to stay on the `Console`? If yes, then perhaps we should drop the `@PreviewFeature` annotation from this new method and introduce it as a regular new API? Same question for the new `readln()` method on the `Console`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21693#discussion_r1822089736 From jpai at openjdk.org Wed Oct 30 08:31:09 2024 From: jpai at openjdk.org (Jaikiran Pai) Date: Wed, 30 Oct 2024 08:31:09 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v3] In-Reply-To: References: Message-ID: On Tue, 29 Oct 2024 08:13:22 GMT, Jan Lahoda wrote: >> This PR is simply adding parameter-less `java.io.IO.{println(),readln()}`, with the (hopefully) obvious semantics, plus the corresponding wiring to make those work. This may become part of JEP 495: >> https://openjdk.org/jeps/495 > > Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision: > > Fixing test for Console.readln/readLine, ensuring the proper methods are called. src/java.base/share/classes/java/io/Console.java line 240: > 238: * if an end of stream has been reached without having read > 239: * any characters. > 240: * Should we specify (both here and in the `IO.readln()`) what is returned if only the line-terminator character is read from the console? A brief look at the implementation seems to suggest that we return an empty `String`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21693#discussion_r1822111523 From duke at openjdk.org Wed Oct 30 09:10:06 2024 From: duke at openjdk.org (Evemose) Date: Wed, 30 Oct 2024 09:10:06 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v3] In-Reply-To: References: Message-ID: On Wed, 30 Oct 2024 08:27:23 GMT, Jaikiran Pai wrote: >> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision: >> >> Fixing test for Console.readln/readLine, ensuring the proper methods are called. > > src/java.base/share/classes/java/io/Console.java line 240: > >> 238: * if an end of stream has been reached without having read >> 239: * any characters. >> 240: * > > Should we specify (both here and in the `IO.readln()`) what is returned if only the line-terminator character is read from the console? A brief look at the implementation seems to suggest that we return an empty `String`. I'm not an expert in this field, but It is pretty common to exclude line terminator from readln string in different languages. Therefore, It should be intuitive that if nothing was present in line, the result of method will be string with noting, i.e. empty string. The method could benefit from some sort of semantic annotation like NonNull, but I guess modern IDEs do pretty good job on inferring such things anyway. PS: Also I feel like for person that never wrote code in their life "line terminator" would sound like some sort of error, maybe the better wording should be used in IO specifically ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21693#discussion_r1822170776 From jlahoda at openjdk.org Wed Oct 30 12:28:11 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Wed, 30 Oct 2024 12:28:11 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v3] In-Reply-To: References: Message-ID: On Wed, 30 Oct 2024 08:17:02 GMT, Jaikiran Pai wrote: >> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision: >> >> Fixing test for Console.readln/readLine, ensuring the proper methods are called. > > src/java.base/share/classes/java/io/Console.java line 184: > >> 182: */ >> 183: @PreviewFeature(feature = PreviewFeature.Feature.IMPLICIT_CLASSES) >> 184: public Console println() { > > Hello Jan, with the introduction of the simplified `java.io.IO` class, some of whose APIs are wrappers around the `java.io.Console` class APIs, it's understandable that we will start seeing new methods being introduced on the `Console` class. > > For this specific new `println()` method on the `Console` class, do you think this method will/should be introduced irrespective of the `IO` class usage? In other words, considering a theoretic case where there may be a situation to abandon the implicit classes preview feature or do it in a different way, would we still want this `println()` method to stay on the `Console`? If yes, then perhaps we should drop the `@PreviewFeature` annotation from this new method and introduce it as a regular new API? Same question for the new `readln()` method on the `Console`. I don't think this PR is the right place to add the methods permanently to `Console`. I am not objecting to that, but it seems the if those would be added independently of `java.io.IO`, it needs a separate discussion and decision. And I believe that, if needed, that should be done outside of and independently on the framework of `java.io.IO` and JEP 495, as both of these are preview features. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21693#discussion_r1822515952 From jlahoda at openjdk.org Wed Oct 30 12:32:10 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Wed, 30 Oct 2024 12:32:10 GMT Subject: RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v3] In-Reply-To: References: Message-ID: On Wed, 30 Oct 2024 09:07:47 GMT, Evemose wrote: >> src/java.base/share/classes/java/io/Console.java line 240: >> >>> 238: * if an end of stream has been reached without having read >>> 239: * any characters. >>> 240: * >> >> Should we specify (both here and in the `IO.readln()`) what is returned if only the line-terminator character is read from the console? A brief look at the implementation seems to suggest that we return an empty `String`. > > I'm not an expert in this field, but It is pretty common to exclude line terminator from readln string in different languages. Therefore, It should be intuitive that if nothing was present in line, the result of method will be string with noting, i.e. empty string. The method could benefit from some sort of semantic annotation like NonNull, but I guess modern IDEs do pretty good job on inferring such things anyway. > > PS: Also I feel like for person that never wrote code in their life "line terminator" would sound like some sort of error, maybe the better wording should be used in IO specifically I also find the current text to be fairly clear. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21693#discussion_r1822523668