The jaotc Command

Name

jaotc - The Java static compiler that produces native code for compiled Java methods

Synopsis

jaotc [options] [name | list]

options
Command-line options separated by spaces. See jaotc Options.
name
The Java class or jar file from which Java methods will be compiled.
list
Colon (:) separated list of class names, modules, jar files or directories which contain class files.

Description

The jaotc command is a Java Ahead-Of-Time (AOT) static compiler which produces native code in the form of a shared library for the Java methods in specified Java class files. The Java Virtual Machine can load these AOT libraries and use native code from them when corresponding Java methods are called. By using jaotc, there is no need to wait for the JIT compiler to generate (by compiling bytecode) the fast native code for these Java methods. The code is already generated by jaotc and ready to be immediately used. For the same reason, there is no need to execute these methods in the Interpreter because fast compiled native code can be executed instead.

Note:

The jaotc command is experimental. See JEP 295: Ahead-of-Time Compilation for complete details.

jaotc Options

--output file
Output file name. Default name is "unnamed.so".
--class-name class-names
List of Java classes to compile.
--jar jar-files
List of JAR files to compile.
--module modules
List of Java modules to compile.
--directory dirs
List of directories to search for files to compile.
--search-path dirs
List of directories to search for specified files.
--compile-commands file

Name of the file containing the compile commands:

exclude
Excludes compilation of specified methods.
compileOnly
Compiles only specified methods.

Regular expressions are used to specify classes and methods. For example:

exclude sun.util.resources..*.TimeZoneNames_.*.getContents\(\)\[\[Ljava/lang/Object; 
exclude sun.security.ssl.* 
compileOnly java.lang.String.*
--compile-for-tiered
Generates profiling code for tiered compilation. By default, profiling code is not generated (could be changed in a future).
--compile-with-assertions
Generates code with java assertions. By default, assertions code is not generated.
--compile-threads number
Sets the number of compilation threads used. The default value is min(16, available_cpus).
--ignore-errors
Ignores all exceptions thrown during class loading. By default, the tool will exit compilation if class loading throws an exception.
--exit-on-error
Exits on compilation errors. By default, failed compilation is skipped and compilation of other methods continues.
--info
Prints information about compilation phases.
--verbose
Prints more details about compilation phases.
--debug
Prints comprehensive details.
--help or -h or -?
Prints a summary of standard options and exits the tool.
--version
Prints version information.
-Jflag
Provides a flag to pass to the runtime system. To pass more than one flag, provide an instance of this option for each flag or flag argument needed.

jaotc Examples

Use the jaotc tool to execute AOT compilation.

jaotc --output libHelloWorld.so HelloWorld.class

Specify a generated AOT library during application execution:

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