On Wed, 29 May 2024 19:51:36 GMT, Naoto Sato <na...@openjdk.org> wrote:

> There is an initialization code in `Console` class that searches for the 
> Console implementations. Refactoring the init code not to use lambda/stream 
> would reduce the (initial) number of loaded classes by about 100 for 
> java.base implementations. This would become relevant when the java.io.IO 
> (JEP 477) uses Console as the underlying framework.

Just to clarify a bit, this is only vaguely related to the implicitly declared 
classes. The actual issue is that having two programs:

public class SystemPrint {
    public static void main(String... args) {
        System.err.println("Hello!");
    }
}

and:

public class IOPrint {
    public static void main(String... args) {
        java.io.IO.println("Hello!");
    }
}

(note there are no implicitly declared classes, and no implicit imports in the 
samples), there is a considerable difference in the runtime of (compiled 
versions) of these classes. E.g. on my laptop:


$ time java -classpath /tmp SystemPrint 
Hello!

real    0m0,035s
user    0m0,019s
sys     0m0,019s

$ time java -classpath /tmp --enable-preview IOPrint 
Hello!

real    0m0,165s
user    0m0,324s
sys     0m0,042s


(Vast) majority of the time is spent in JLine initialization. There's 
https://bugs.openjdk.org/browse/JDK-8333086 for that, where the intent is to 
avoid initializing JLine for simple printing. There may be other opportunities 
to make JLine initialization faster in case we need to initialize it.

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

PR Comment: https://git.openjdk.org/jdk/pull/19467#issuecomment-2139255172

Reply via email to