On Thu, 29 Jan 2026 21:08:06 GMT, Naoto Sato <[email protected]> wrote:
> Fixing an issue in Console where write is blocked if other thread is waiting
> to read, which is caused by unnecessary read/write locks. Removing those
> would solve the problem, as the read/write synchronization is performed at
> the StreamEn/Decoder level. One unrelated change is to refactor
> double-checked locking with LazyConstant.
src/java.base/share/classes/java/io/ProxyingConsole.java line 37:
> 35: * provided with jdk.internal.io.JdkConsoleProvider.
> 36: */
> 37: final class ProxyingConsole extends Console {
Would it make sense to make all the classes in this file records and/or value
classes, as all the fields are `final`?
src/java.base/share/classes/java/io/ProxyingConsole.java line 40:
> 38: private final JdkConsole delegate;
> 39: private final LazyConstant<Reader> reader =
> LazyConstant.of(this::initReader);
> 40: private final LazyConstant<PrintWriter> printWriter =
> LazyConstant.of(this::initPrintWriter);
Great to see `LazyConstant` replacing DCLs! I wonder if we should use an
anonymous class here rather than a lambda to improve startup time? I've made
that in some other places in the JDK. Something to think about.
src/java.base/share/classes/java/io/ProxyingConsole.java line 53:
> 51: @Override
> 52: public PrintWriter writer() {
> 53: PrintWriter printWriter = this.printWriter;
So nice to get rid of such code segments!
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29493#discussion_r2746083379
PR Review Comment: https://git.openjdk.org/jdk/pull/29493#discussion_r2746092237
PR Review Comment: https://git.openjdk.org/jdk/pull/29493#discussion_r2746098793