RFR: 8342936: Enhance java.io.IO with parameter-less println() and readln() [v3]

Jaikiran Pai jpai at openjdk.org
Sun Nov 3 07:14:29 UTC 2024


On Wed, 30 Oct 2024 12:25:34 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> 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.

Hello Jan, I agree that if we are going to introduce the parameter-less `println()` and `readln()` APIs on `Console` class independently of the preview feature, then it should be done in a separate PR and with a separate discussion. I was going to suggest that we should probably do that, but I notice that the existing `readln` and `println` methods which take a parameter are already marked preview feature methods in Java 23 https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/io/Console.html#preview-println(java.lang.Object). Given that, I believe what you have here in this PR - marking these new parameter-less methods on `Console` as preview feature, is the right thing to do.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21693#discussion_r1826918451


More information about the core-libs-dev mailing list