On Mon, 19 Dec 2022 19:23:25 GMT, Naoto Sato <na...@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

Reply via email to