Fork me on GitHub

Introduction

The Hotspot JVM allows to provide a command file for the JIT compiler (see -XX:CompileCommandFile).

Using this project, you can generate this file automatically from annotations in the source code.

Disclaimer

The Hotspot JIT does a tremendous work optimizing your code, don’t see this as “@Inline for the masses” : this is not a cheap way to make your code faster.

Also, this is not portable and uses an internal feature of the Hotspot JVM.

Only use this if you know what you are doing and have a good reason to.

Usage

  • Add the jar to your compilation classpath (or grab it directly at Maven central repository):

    <dependencies>
      <dependency>
        <groupId>net.ju-n.compile-command-annotations</groupId>
        <artifactId>compile-command-annotations</artifactId>
        <version>1.2.0</version>
        <optional>true</optional>
      </dependency>
    </dependencies>
    
  • Add annotations in your source code :

    @Inline
    public void method01() {
    }
    

    See samples and integration tests.

  • When your program is compiled, the file is generated at META-INF/hotspot_compiler

  • You can then run your program using the compile command file:

    java -XX:CompileCommandFile:target/classes/META-INF/hotspot_compiler ...