GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • java.evolved
  • ←
  • →

This view

  • Original page
  • New address

GeezerVison is showing javaevolved.dev — AOT class preloading | java.evolved

Home / Tooling / AOT class preloading
Tooling Advanced

AOT class preloading

  • 🐛 Report a code issue
  • 🌐 Report a translation issue
  • 💡 Suggest a new pattern

Cache class loading and compilation for instant startup.

Performance Tooling
Code Comparison
✕ Java 8
// Every startup:
// - Load 10,000+ classes
// - Verify bytecode
// - JIT compile hot paths
// Startup: 2-5 seconds
✓ Java 25
// Training run:
$ java -XX:AOTCacheOutput=app.aot \
    -cp app.jar com.App
// Production:
$ java -XX:AOTCache=app.aot \
    -cp app.jar com.App
Share 𝕏
See a problem with this code? Let us know.
Why the modern way wins
⚡

Faster startup

Skip class loading, verification, and linking.

📦

Cached state

Training run captures the ideal class state.

🔧

No code changes

Works with existing applications — just add JVM flags.

Old Approach
Cold Start Every Time
Modern Approach
AOT Cache
Since JDK
25
Difficulty
Advanced
JDK Support
AOT class preloading
Available

Available as a standard feature in JDK 25 LTS (JEPs 514/515, Sept 2025).

How it works

AOT class preloading caches loaded and linked classes from a training run. On subsequent starts, classes are loaded from the cache, skipping verification and linking. Combined with AOT compilation, this dramatically reduces startup time.

Related Documentation
Ahead-of-Time Command-Line Ergonomics (JEP 514) ↗ AOT Cache (JEP 515) ↗
Related patterns
Tooling Beginner

JShell for prototyping

Java 8
// 1. Create Test.java
// 2. javac Test.java
// 3. java Test
// Just to test one expression!
Java 9+
$ jshell
jshell> "hello".chars().count()
$1 ==> 5
jshell> List.of(1,2,3).reversed()
$2 ==> [3, 2, 1]
Hover to see modern ➜
JDK 9+ →
Tooling Beginner

Single-file execution

Java 8
$ javac HelloWorld.java
$ java HelloWorld
// Two steps every time
Java 11+
$ java HelloWorld.java
// Compiles and runs in one step
// Also works with shebangs:
#!/usr/bin/java --source 25
Hover to see modern ➜
JDK 11+ →
Tooling Intermediate

Multi-file source launcher

Java 8
$ javac *.java
$ java Main
// Must compile all files first
// Need a build tool for dependencies
Java 22+
$ java Main.java
// Automatically finds and compiles
// other source files referenced
// by Main.java
Hover to see modern ➜
JDK 22+ →
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.