RFR: 8305457: Implement java.io.IO [v9]

Stuart Marks smarks at openjdk.org
Wed May 15 00:05:04 UTC 2024


On Tue, 14 May 2024 14:31:52 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

>> src/java.base/share/classes/java/io/IO.java line 98:
>> 
>>> 96:      *                 or if an I/O error occurs
>>> 97:      */
>>> 98:     public static String readln(String prompt) {
>> 
>> Did we consider Optional<String> here? Maybe that is to complicated for an onramp?
>
> Have we considered it? Yes, momentarily. Will we implement it here? No, certainly.

The precedent to return `null` from something that reads a line has already been set by `BufferedReader.readLine()` and `Console.readLine()`.

`Optional` is indeed intended for return values but it probably works better for things that are totally new, such as various streams operation (for which `Optional` was introduced), modules, the Classfile API, HTTP client, etc. And to use `Optional` effectively one needs to know how to use lambdas, the teaching of which is probably at odds with the on-ramp story.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19112#discussion_r1600793369


More information about the core-libs-dev mailing list