RFR: 8305457: Implement java.io.IO [v3]
Jaikiran Pai
jpai at openjdk.org
Wed May 8 10:34:53 UTC 2024
On Wed, 8 May 2024 08:59:18 GMT, Pavel Rappo <prappo at openjdk.org> wrote:
>> src/java.base/share/classes/java/io/Console.java line 192:
>>
>>> 190: *
>>> 191: * @param prompt
>>> 192: * A prompt string.
>>
>> Hello Pavel, should this specify whether `prompt` can be null?
>
> If we specify that, it would be very much unlike all other `Console` methods that are covered by this:
>
> * Unless otherwise specified, passing a {@code null} argument to any method
> * in this class will cause a {@link NullPointerException} to be thrown.
I haven't given it a try, but a brief look at the code suggests that if the console implementation backed by JLine gets used, then a `null` prompt may not generate a `NullPointerException` (since JLine appears to allow `null`) whereas if the internal JDK console implementation gets used then a `NullPointerException` will get thrown. If the expectation is to disallow a `null` prompt, then perhaps `Objects.requireNonNull(prompt)` before we hand off to the underlying console implementations might be required.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19112#discussion_r1593809280
More information about the core-libs-dev
mailing list