Project Leyden: Making Java Start Like a Script

Java pays a startup tax on every launch — loading, linking, and warming thousands of classes. Project Leyden's ahead-of-time cache shifts that work earlier in time. Here's what's already shipped, what's still in the lab, and how to try it today.

java -jar shop.jar on a cold machine. The cursor blinks. One second. Three seconds. Five. Your Spring Boot app is doing real work — just not your work. It’s scanning JARs, parsing bytecode, verifying classes, resolving symbolic references, and interpreting methods while the JIT compiler watches and takes notes. Java’s famous dynamism — load anything, link anything, reflect on everything, at any time — is paid for on every single launch.

Project Leyden is OpenJDK’s plan to stop paying that tax at startup. Its stated goal is to “improve the startup time, time to peak performance, and footprint of Java programs,” and its strategy is a time machine: take work the JVM currently does just in time and shift it ahead of time, into a build-like step. Crucially, it does this without giving up the dynamism — unlike native-image approaches, Leyden keeps the full HotSpot JVM, reflection and all.

This post is the honest field guide: what has actually shipped in released JDKs, what the commands look like, what the numbers say — and what’s still in the lab.

Where a cold start actually spends its time

Before touching Leyden, you need the anatomy of the tax. A cold JVM startup runs through five phases, in order:

Five JVM startup phases — JVM launch, class loading, linking, interpreter warmup, JIT compilation — and the Leyden JEP that improves each
The five startup phases, and which Leyden JEP attacks each one. JVM launch itself barely moves — Leyden optimizes what happens after the runtime boots.

Class loading is usually the biggest line item for large apps: class loaders walk the classpath, find .class files on disk, parse the bytecode, and build Class objects — lazily, on demand, thousands of times. Linking follows each load: bytecode verification, field and method layout, and resolution — turning symbolic references (“some method on some class”) into direct pointers. Then interpreter warmup: methods run slowly in the interpreter while HotSpot counts invocations and branch frequencies, because the JIT compiler needs that profile data before it dares to generate optimized native code.

Leyden’s insight is that for a given application, phases 2 through 4 are almost entirely deterministic. The same classes load, link the same way, and profile roughly the same. So record them once — in a training run — and replay them instantly on every later start.

JEP 483: the AOT cache (JDK 24)

The first shipped piece is JEP 483: Ahead-of-Time Class Loading & Linking, delivered in JDK 24. It extends HotSpot with an ahead-of-time cache that stores classes “after reading, parsing, loading, and linking them.” Create the cache once for your application, and subsequent runs reuse it to start faster.

Two things make it more than the old Class Data Sharing (CDS) archive it grew out of — the JEP describes the AOT cache as the natural evolution of CDS:

  1. Bulk loading. Instead of loading classes one at a time from disk, classes in the cache are bulk-loaded during JVM startup.
  2. Ahead-of-time linking. Some symbolic references between cached classes are resolved ahead of time and replaced with direct pointer references. At startup, that linking work is already done.

What goes into the file, then, is not source, not bytecode, and not native code — it’s state: loaded and linked classes, plus (since JDK 25) method profiles.

A training run records loaded classes, linked classes, and method profiles into app.aot; production runs load them instantly from the cache
The AOT cache holds state, not code: loaded and linked classes (JEP 483), plus method profiles from JDK 25 (JEP 515). Compiled native code is not in there yet.

The workflow, verified

The original JDK 24 workflow is a three-command dance. First a training run records an AOT configuration:

java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconf \
  -cp app.jar com.example.App ...

Then a create step builds the cache from that configuration (it doesn’t run your app — it just builds app.aot):

java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconf \
  -XX:AOTCache=app.aot -cp app.jar

Then production runs use the cache:

java -XX:AOTCache=app.aot -cp app.jar com.example.App ...

Every one of those flags is real and current. Two resilience details from the JEP worth knowing: if the cache file is missing or unusable, the JVM issues a warning and starts normally — the cache is an optimization, never a dependency. And the file format is explicitly JVM-private and subject to change, so don’t treat app.aot as a build artifact you ship around casually; regenerate it with the JDK you run.

Compatibility is the whole point

The reason Leyden matters more than yet another startup trick is the compatibility story, and the JEP is explicit: ahead-of-time class loading and linking “works with every existing Java application, library, and framework. It requires no changes to source code and no changes to build configurations,” and it “fully supports the highly dynamic nature of the Java Platform, including run-time reflection.”

How? Because the Java language and VM specifications never promised your code when loading and linking happen — only that it looks as if they happened at the moment requested. The JEP’s phrasing is lovely: the application “observes classes being loaded and linked as if the JVM did that work at the exact moment requested — though unaccountably fast.”

One command to train them (JEP 514, JDK 25)

Running java twice to build a cache was clunky, so JEP 514: Ahead-of-Time Command-Line Ergonomics (JDK 25) collapsed the common case into one training command:

# training run that records AND creates the cache in one go
java -XX:AOTCacheOutput=app.aot -cp app.jar com.example.App ...

# production run, unchanged
java -XX:AOTCache=app.aot -cp app.jar com.example.App ...

Drive your application through its representative paths during that training run, stop it, and app.aot is sitting next to your JAR. If you want to watch what the cache is doing, -Xlog:aot logs AOT cache activity.

Warmup is next: JEP 515 and JEP 516

JEP 483 killed most of the loading tax, but the warmup tax remained: the JIT still had to wait for profiles to be collected before generating good native code. JEP 515: Ahead-of-Time Method Profiling (JDK 25) fixes that by making “method-execution profiles from a previous run of an application instantly available, when the HotSpot Java Virtual Machine starts,” which “will enable the JIT compiler to generate native code immediately upon application startup, rather than having to wait for profiles to be collected.” Same cache file, same training run — now it also carries the profiles.

Then JEP 516: Ahead-of-Time Object Caching with Any GC (JDK 26) extended the cache to work with any garbage collector.

The honest status table

This is where most blog posts about Leyden go sideways, so here it is plainly — GA vs. in-development as of late 2026:

JEPWhat it doesStatus
483AOT cache: ahead-of-time class loading & linkingDelivered, JDK 24
514One-command cache creation (-XX:AOTCacheOutput)Delivered, JDK 25
515Method profiles in the cache → faster warmupDelivered, JDK 25
516AOT cache works with any GCDelivered, JDK 26
—AOT code compilation (methods arrive pre-compiled)In development

That last row is the one people assume already shipped. It has not. The official Leyden project page lists “Ahead-of-Time Code Compilation” as in progress (TBD), with active work on the premain branch and early-access builds published at jdk.java.net/leyden. Those EA builds are where you can try experimental goodies like AOT compilation of Java methods and AOT generation of dynamic proxies and reflection data — but none of it is in a released JDK, including JDK 27. If someone shows you a “Leyden AOT compilation” tutorial using a GA JDK, they’re confused.

What the numbers actually say

The JEP 483 report includes its own measurements, and they’re refreshingly honest about the shape of the win. Two workloads, three configurations:

HelloStream (tiny CLI)PetClinic (Spring Boot)
JDK 23, no cache0.031s4.486s
AOT cache, no loading/linking0.027s (+13%)3.008s (+33%)
AOT cache, with loading & linking0.018s (+42%)2.604s (+42%)

Two observations. First, the full win needs the linking half — a plain class cache gets you a third of the way there; pre-resolved references get you the rest. Second, the bigger the app, the bigger the absolute saving: ~13ms on a toy, ~1.9 seconds on PetClinic. Leyden is a tax cut that scales with how much tax you were paying.

Cold JVM startup timeline versus AOT-cached startup: class loading, linking, and warmup phases shrink dramatically
The shape of the win: class loading and linking nearly vanish, warmup shrinks with JEP 515. Proportions illustrative — the real numbers are the JEP 483 table above.

Try it live: the startup lab

Enough theory. Below is a startup laboratory: pick a workload, flip the AOT cache on, and watch the timeline phases shrink per JEP. The preview toggle shows what experimental AOT code compilation would do to the JIT phase — clearly labeled as not-yet-shipped.

STARTUPLAB — LIVE
Startup time, simulated
Pick a workload, then switch the AOT cache on and watch which phases shrink — and by how much. All figures are illustrative estimates, not measured benchmarks.
1 · Workload
2 · AOT cache
cold start
4.49s
with AOT cache
4.49s
switch the cache on to see the savings
Phase-by-phase timeline (same scale)
cold
cached
JVM launch
Class loading
Linking
Interpreter warmup
JIT compilation
Where the savings come from
No cache, no savings — pick “Classes” or “Classes + profiles” above to see which phases pay out.
The commands for this setup (verified flags)
$ java -cp shop.jar com.example.Shop
Note: this simulates per-phase savings in your browser — no JVM was started. Figures are illustrative estimates, not measured benchmarks; the model roughs in the JEP 483 report (PetClinic 4.486s → 2.604s, HelloStream 0.031s → 0.018s). AOT code compilation is still in development on the Leyden premain branch.

Three things to notice while you play. First, class loading dominates the savings — it’s the phase Leyden attacks most directly, and it’s why big apps win biggest. Second, JEP 515’s profiles don’t make startup instant; they make warmup shorter by letting the JIT compile immediately instead of waiting for data. Third, even the experimental code-compilation preview leaves a residual JIT cost — the JVM keeps profiling and recompiling in production, because real behavior can differ from the training run.

Practical notes before you try it

Your training run is your cache. The cache only contains what the training run exercised. Drive the app through its representative paths — hit the endpoints, warm the code paths you care about — or the cache won’t cover them. (The Leyden team has a whole design note on training runs; treat them as a real step, not a formality.)

Rebuild the cache when the code changes. The cache is tied to the classes it was built from. It belongs in your build/deploy pipeline next to the JAR, regenerated with the same JDK you run in production — remember, the format is JVM-private and version-specific.

Watch the edges. AOT class linking changes the order in which classes load (bulk-loaded at startup instead of lazily), and while the spec never guaranteed an order, some applications and tools assumed one. Monitoring vendors have flagged real edges — Dynatrace, for example, documented that its JVMTI-based OneAgent is incompatible with AOT class loading enabled. Test with your agents and instrumentation on.

It composes with everything else. Because Leyden keeps the full JVM, it stacks with the other startup tricks you already know: -Xshare CDS habits, AppCDS, ahead-of-time-friendly frameworks like Quarkus (which has first-class quarkus.package.jar.aot support), and eventually CRaC checkpoint/restore. The cache doesn’t replace your tuning; it removes the floor underneath it.

The takeaway

Project Leyden is Java growing a build step — not for your code, but for your runtime’s work. The shipped JEPs (483, 514, 515, 516) already cover the loading and warmup tax with real commands you can run on a released JDK today, full dynamism intact. The headline act — arriving with methods already compiled — is still in the lab, and now you know exactly which row of the status table it’s sitting in.

Sources

Keep reading