JEP 483: Ahead-of-Time Class Loading & Linking. Project Leyden in JDK 24

Transcript 


In this video, we'll look at JEP 483: Ahead-of-Time Class Loading and Linking, which is targeted for JDK 24 and marks the initial introduction of Project Leyden into the mainline OpenJDK. When Java applications start, necessary application classes and core JVM classes must be loaded and initialized. There can be thousands of classes, so this process affects the startup times of Java applications. The worst part is that this process repeats every time the application starts.

One way to deal with this issue is to use Application Class Data Sharing (AppCDS), a JVM feature that reads and parses a set of application and JVM classes, storing this data in a read-only archive. When the application starts, the JVM reads the data from the archive, speeding up the startup process. Ahead-of-Time (AOT) class loading and linking goes even further. It not only reads and parses but also loads and links classes, storing this data in an AOT cache. As a result, the JVM has even less work to do at startup. This feature aligns with the overall goal of Project Leyden, which aims to shift some computations from the production run to earlier stages, such as trial runs. AOT class loading and linking is the first step towards introducing Project Leyden to OpenJDK.

You create the AOT cache once, and it can be reused every time your application starts. This feature is compatible with any Java application and doesn’t require changes to the application code. The only requirement is to perform a training run for your application to record its AOT configuration. The more efficient the training run, the better the resulting AOT cache. The training run should mimic the production run, allowing the application to fully configure itself and execute production code paths.

Now, let’s try this feature with the early access builds of JDK 24. For this experiment, I’ve downloaded early access builds of JDK 24, which you can also get for your platform. Note that the results we’ll get are preliminary and may change when stable builds are released. But we’re just testing the waters, right? Take any Spring app you like. I’m using a Spring Boot-based CRUD application that manages personal tasks. It’s a simple app with basic functionality. You can follow along or experiment with your own application.

Let’s first create a JAR file using maven clean package. Running the executable JAR in production is not recommended by the Spring team, so we’ll create an exploded JAR instead. For this, we’ll use the Djarmode=tools option to extract the JAR. Now we have our extracted JAR with the lib subdirectory and the JAR file itself. Let’s first run the application with the JAR file to see how fast it starts without any optimizations. As you can see, the application started in about two seconds.

All right, let’s get down to business. To create an AOT cache, we need to perform two steps (although it’s planned to merge them into one step in the future). First, conduct a trial run of your application with two flags: -XX:AOTMode=record and -XX:AOTConfiguration to record its AOT configuration into the file app.aotconf. Now, push some buttons in the application so it performs useful operations. Next, use the configuration file to create the cache. For this, use three flags: -XX:AOTMode=create, -XX:AOTConfiguration pointing to app.aotconf, and -XX:AOTCache to create the cache named app.aot. This step doesn’t run the application; it only creates the cache.

Now we can run the application. This time, we only need one flag: -XX:AOTCache pointing to the cache file we created earlier. As you can see, the application started in just one second, which is pretty cool.

In this video, we explored a new JDK feature, Ahead-of-Time Class Loading and Linking, aimed at reducing the startup times of Java applications. If you like this video, subscribe to our channel. And until next time!

Summary

JEP 483 introduces Ahead-of-Time (AOT) Class Loading and Linking in JDK 24, which enhances Java application startup times by loading and linking classes ahead of time and storing them in a reusable AOT cache. This feature, part of Project Leyden, reduces the JVM's workload during startup without requiring changes to application code, though a training run mimicking production is needed to create an efficient cache. Early tests with a Spring Boot app showed significant improvements, cutting startup time from two seconds to just one second.

About Catherine

Java developer passionate about Spring Boot. Writer. Developer Advocate at BellSoft

Social Media

Videos
card image
Aug 6, 2025
GraalVM for Java Developers: The Ultimate Beginner’s Guide

What is GraalVM and how can it improve your Java applications? In just 10 minutes, this video explains the three main components of GraalVM — the JIT compiler, Native Image, and Polyglot API. Learn how to boost performance, reduce startup time, and combine multiple languages in one app. Whether you’re building microservices, serverless apps, or just exploring modern JVM tooling, this is your quick-start guide to GraalVM.

Videos
card image
Jul 15, 2025
Java Downgrade Challenge: From JDK 8 to 1.1 (Part 2)

In Part 2 of the Java Downgrade Challenge, we continue our journey — now from Java 8 all the way to Java 1.1. No streams, no lambdas, no generics, no collections — and at one point, we even boot up Windows 98. If you thought Part 1 was painful, this one unwinds Java history line by line. By the end, the familiar Java from today will be almost gone.

Further watching

Videos
card image
Aug 27, 2025
Buildpacks for Spring Boot

Buildpacks for Spring Boot: no Dockerfiles, no hassle — just production-ready container images in one command. Tired of maintaining Dockerfiles? In this tutorial, you’ll learn how to use buildpacks to create optimized Spring Boot containers — fast, secure, and cloud-ready — with just one command. We’ll show what happens under the hood: automatic dependency detection, layered image creation, memory tuning, SBOM generation, and how to tweak builds with just a few plugin options. Need faster startup, smaller image size, or JFR monitoring? Buildpacks can handle it — and we’ll show you how.

Videos
card image
Aug 20, 2025
Flyway in Spring Boot: Step-by-Step tutorial with Maven

Learn how to use Flyway in Spring Boot with Maven for smooth and reliable database migrations. In this hands-on tutorial, we cover everything from setting up PostgreSQL in Docker, configuring Flyway in your application, writing versioned and repeatable migrations, to using Flyway in CI/CD pipelines with GitHub Actions. Whether you’re new to Flyway or want to master schema version control in Spring Boot, this video will guide you step by step.

Videos
card image
Aug 14, 2025
Stop Using DTOs – A Cleaner Way for Your Java APIs

Still creating DTOs for every API in your Spring Boot project? You might be overcomplicating things. In this video, we show why DTOs aren’t always necessary and how to replace them with @JsonIgnore, @JsonView, and Jackson Mixins. You’ll see real examples of hiding sensitive fields, creating role-based views, and cutting boilerplate — all while keeping your API safe, clean, and easy to maintain.