search
But here's the catch

Java 9 will support Ahead-of-Time compilation

JAX Editorial Team
Java 9
Modern hourglass image via Shutterstock

Java 9 will support Ahead-of-Time compilation but the initial release is only supported on 64-bit Linux systems running 64-bit Java and the only supported module is java.base. Let’s see what this means.

Java 9 will support Ahead-of-Time (AOT) compilation to boost the start-up time of small and large Java applications, with at most a limited impact on peak performance, according to the announcement. Ahead-of-Time compilation is needed because even though JIT compilers are fast, “Java programs can become so large that it takes a long time for the JIT to warm up completely.” Plus, it might happen that Java methods which are not frequently used are not compiled at all, which may trigger a performance penalty due to repeated interpreted invocations.

However, it is worth noting that the only supported module is java.base. The reason behind this decision is to reduce the problem space “since the Java code in java.base is well-known in advance and can be thoroughly tested internally.” The user must compile the module and copy the resulting AOT library into the JDK installation directory, or specify it on java command line. jaotc, a new tool will be used:

jaotc --output libHelloWorld.so HelloWorld.class
jaotc --output libjava.base.so --module java.base

jaotc is part of java installation – same as javac.

jaotc --output libHelloWorld.so HelloWorld.class

Users must specify generated AOT library during application execution:

java -XX:AOTLibrary=./libHelloWorld.so HelloWorld

This tool can be used the same way as javac.

jaotc<options> <--module name>

or

jaotc<options> <list of classes or/and jar files>

SEE ALSO: Java 9 delayed to July 2017: “Jigsaw needs more time”

Limitations

Ahead-of-Time is only supported on 64-bit Linux systems running 64-bit Java and the only supported module for AOT compilation will be java.base. It may not compile java code which uses dynamically generated classes and bytecode and it should be executed on the same system or a system with the same configuration on which AOT code will be used by Java application. 

Plus, not all applications benefit from AOT-compiled code. Because this is an opt-in feature, possible performance regressions with user applications can be avoided. If users notice that an application either starts up more slowly or does not reach the expected peak performance, they can switch AOT off with the -XX:-UseAOT flag, or remove any AOT libraries. 

Read here the entire announcement.

Comments
comments powered by Disqus