Scroll to navigation

JAOTC(1) JDK Commands JAOTC(1)


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


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


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.


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


--output file
Output file name. Default name is "".
--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:
Excludes compilation of specified methods.
Compiles only specified methods.

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

exclude sun.util.resources..*.TimeZoneNames_.*.getContents\(\)\[\[Ljava/lang/Object; 
compileOnly java.lang.String.*

Generates profiling code for tiered compilation. By default, profiling code is not generated (could be changed in a future).
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).
Ignores all exceptions thrown during class loading. By default, the tool will exit compilation if class loading throws an exception.
Exits on compilation errors. By default, failed compilation is skipped and compilation of other methods continues.
Prints information about compilation phases.
Prints more details about compilation phases.
Prints comprehensive details.
--help or -h or -?
Prints a summary of standard options and exits the tool.
Prints version information.
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.


Use the jaotc tool to execute AOT compilation.

jaotc --output HelloWorld.class


Specify a generated AOT library during application execution:

java -XX:AOTLibrary=./ HelloWorld

2019 JDK 13