RFR: 8298416: Console should be declared `sealed` [v2]

Alan Bateman alanb at openjdk.org
Wed Dec 14 08:53:09 UTC 2022


On Tue, 13 Dec 2022 18:29:31 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> `Console` class now has a couple of internal subclasses within `java.io` package. It should be `sealed` and subclasses be declared in the `permits` clause. The implementation resided in `Console` class is separated into `ConsoleImpl` class.
>
> Naoto Sato has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
> 
>  - Making fields final, other clean-ups
>  - Merge branch 'master' into JDK-8298416-SealedConsole
>  - tidying up
>  - sealed Console, impl/if separation

src/java.base/share/classes/java/io/Console.java line 359:

> 357:      * @return true if the previous console echo status is on
> 358:      */
> 359:     static native boolean echo(boolean on) throws IOException;

I think echo should move to ConsoleImpl too. It might be okay to leave the native method in Console_md.c, then it would be just renaming the JNI function.

src/java.base/share/classes/java/io/Console.java line 417:

> 415:     private static native boolean istty();
> 416: 
> 417:     Console() {}

What would you think about moving the no-arg constructor to the top of the method as it's not easy to spot.

src/java.base/share/classes/java/io/ConsoleImpl.java line 39:

> 37: 
> 38: final class ConsoleImpl extends Console
> 39: {

I assume the "{" can be moved to the previous line, it looks odd here.

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

PR: https://git.openjdk.org/jdk/pull/11615


More information about the core-libs-dev mailing list