RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v3]
Jan Lahoda
jlahoda at openjdk.org
Wed Oct 30 12:32:10 UTC 2024
On Wed, 30 Oct 2024 09:07:47 GMT, Evemose <duke at openjdk.org> 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
More information about the core-libs-dev
mailing list