RFR: 8298971: Move Console implementation into jdk internal package

Jaikiran Pai jpai at openjdk.org
Tue Dec 20 14:26:49 UTC 2022


On Mon, 19 Dec 2022 19:23:25 GMT, Naoto Sato <naoto at openjdk.org> wrote:

> Moving the built-in implementation of `Console` from `java.io` package into `jdk.internal.io` package. It now implements `JdkConsole` interface and is accessed through `ProxyingConsole`.

src/java.base/share/classes/jdk/internal/io/JdkConsoleImpl.java line 336:

> 334:     public JdkConsole console(boolean isTTY, Charset charset) {
> 335:         if (isTTY) {
> 336:             if (INSTANCE == null) {

This would need a double checked locking, isn't it? Something like:

if (INSTANCE == null) {
   synchronized (JdkConsoleImpl.class) {
      if (INSTANCE != null) {
          return INSTANCE;
      }
      ...// rest of the current code that's in if block


Having said that perhaps the singleton instance isn't needed here and the `java.io.Console` deal with the caching?

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

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


More information about the core-libs-dev mailing list