Scrivio Interview library
LeadershipPrincipal7 min read · updated 12 November 2026

Leadership asks whether the company should bet on GraalVM native images or on the JDK's own AOT cache work (Project Leyden) for faster startup and lower memory across its Java fleet. As the senior technical leader, how do you frame the decision over the next five years?

I would not frame it as a single bet. GraalVM native images give the best startup and memory today, but they demand closed-world compatibility, long builds and different tooling, while the JDK's AOT cache keeps full JVM behaviour and needs only a training run, with smaller gains that grow with each release. So I would adopt the AOT cache as the low-risk default for the fleet, support native images where they clearly pay off, and review the split at set points tied to JDK releases and measured results.

Background to this question

Startup time and memory per instance turn directly into cloud cost, autoscaling speed and how many services fit on a node, so leadership is right to ask. The question is really about deciding under uncertainty: two technologies are moving fast, and a five-year mandate made today could lock the company into the wrong one. In this answer, we will recap what each technology does, compare what each one costs us, look at the ecosystem around them, and then build a five-year plan that keeps both doors open.

1A Quick Recap of the Two Approaches

A normal Java service starts slowly because the JVM does a lot of work at startup. It loads and verifies thousands of classes, runs static initialisers. Only later does the JIT compiler, the part of the JVM that turns hot bytecode into machine code while the program runs, make the code fast.

GraalVM native image moves almost all of that work to build time. The build analyses the application under a closed-world assumption, which means every class, method and resource the program can ever use must be known when we build. It then compiles everything into a single native executable.

Project Leyden is the OpenJDK effort to bring startup gains to the normal JVM without changing its rules. Its first result, the AOT cache, arrived in JDK 24 (JEP 483, ahead-of-time class loading and linking) and was extended in JDK 25 with simpler command-line options and stored method profiles; check your version for the exact features. We run the application once in a training run, the JVM records which classes it loaded and linked, and later runs start from that cache. Everything else stays standard Java: reflection, dynamic proxies, Java agents and the JIT all work as before.

Java
# JDK 25 style: one training run writes the cache
java -XX:AOTCacheOutput=app.aot -jar orders.jar # run typical traffic, then stop
# production runs read it
java -XX:AOTCache=app.aot -jar orders.jar # startup often 30-50% faster; check on your service

Notice that the AOT cache needs no code change and no special build. That single fact drives most of the risk comparison that follows.

2What Each Option Costs Us

The honest comparison is not just startup numbers. Native images win on startup and memory today, often by a wide margin. In exchange, every library that uses reflection, dynamic proxies or resources needs reachability metadata, small JSON files that tell the native build what the closed-world analysis cannot see. Spring Boot generates much of this through its AOT processing, and the GraalVM reachability metadata repository covers many popular libraries, but each team still finds gaps, usually as a failure at runtime that never appeared on the JVM. Builds take minutes and several gigabytes of memory, so CI capacity grows. Peak throughput can also be lower than a warmed-up JIT unless we use profile-guided optimisation, and debugging and profiling use different tools.

The AOT cache gives smaller gains, but it costs almost nothing to adopt. The main work is adding a training step to the build pipeline and making sure the cache is created with the same JDK and the same class path as production, because a mismatched cache is simply ignored.

Native image and AOT cache side by side
ConcernGraalVM native imageJDK AOT cache (Leyden)
StartupFastest, often sub-secondFaster than plain JVM, gains growing
MemoryLowest footprintClose to the normal JVM
CompatibilityClosed world, needs reachability metadataFull JVM behaviour
BuildMinutes and GBs of memory per serviceOne extra training run
Peak throughputCan trail JIT without PGOSame JIT as today
Agents and toolingJava agents do not work; different toolsExisting agents, JFR, profilers work
The gap in startup is real today; the gap in risk is just as real.

So the trade is clear: native images buy the largest gain with the largest compatibility and tooling cost, while the AOT cache buys a moderate, growing gain with almost no compatibility risk.

3Ecosystem Support Decides More Than Benchmarks

A fleet is not one service, so we have to look at what every service depends on. Spring Boot supports both paths: it has first-class native image support through AOT processing, and it can use the JDK's class data sharing and AOT cache features. Many libraries, though, still rely on runtime reflection or bytecode generation, and some only work in a native image with metadata that someone has to write and keep up to date.

Observability is the part leaders most often miss. Many companies attach a Java agent, such as the OpenTelemetry Java agent or a vendor APM agent, which rewrites bytecode as classes load. That does not work in a native image, so native services need library-based instrumentation instead, and their dashboards may look different from the rest of the fleet. Maintaining reachability metadata is a recurring cost too: every library upgrade can break a native build, and someone must own the fix. I would ask a platform team to estimate that cost in engineer weeks per year before anyone counts the savings.

4Framing the Decision as Options, Not a Mandate

With those facts, the decision stops being native versus Leyden. The bets are not exclusive. The AOT cache becomes the default in the golden path, the paved road of templates and pipelines that most services follow, because it is low risk and benefits everyone. Native images become a supported option for workloads where they clearly pay off: functions and jobs that start per request, services that scale to zero, command-line tools, and very high replica counts where memory per pod dominates cost.

To decide where native pays off, I would ask for numbers from real services, not samples. For example, if a service runs 400 pods at 1 GB each and native saves 40 percent of memory, that is about 160 GB of capacity, which is worth a team's effort.

Step throughChoosing the startup option for a service
  1. Start every service on the JDK AOT cacheDefault in the golden path
  2. Is startup or memory a top cost driver?
    YesMeasure a native build of itNoStay on the AOT cache
  3. Do its libraries and agents work natively?
    YesRun a production pilotNoStay on the AOT cache
  4. Savings exceed build and metadata cost?
    YesSupport it as nativeNoStay on the AOT cache

4 steps in order. Play them, or step through them one at a time.

Native is earned by evidence, service by service.

5Review Points Over Five Years

Five years is long in this space. JDK feature releases come every six months and LTS releases every two years, and both GraalVM and Leyden are changing quickly. An irreversible mandate in either direction would be a mistake. Instead, I would tie review points to the JDK LTS releases and to fleet data: each review looks at measured startup, memory, cost per request, incident counts caused by native builds, and the effort spent on metadata.

I would also define in advance what would change the decision. If Leyden's later work closes most of the startup gap, we shrink the native footprint. If native tooling and agent support mature and the savings stay large, we widen it.

6Follow-up questions

What would you tell a team that wants to go native right now?

I would say yes if they bring numbers: their current startup time, memory per pod and replica count, a native build that passes their full test suite, and a plan for observability without a Java agent. The platform supports them with templates and CI capacity, and in return they own the reachability metadata for their libraries. If the expected saving is small, I would steer them to the AOT cache first, because it gives part of the gain with almost none of the risk.

Does the AOT cache help memory as well as startup?

Mostly it helps startup and warm-up, because classes are already loaded and linked from the cache. The memory footprint stays close to a normal JVM, since the JIT, the class metadata and the heap are all still there. That is exactly why native images keep a place for memory-bound workloads, and why the plan measures both numbers separately.

7Conclusion

In this answer, we saw that native images and the JDK AOT cache solve the same problem with very different costs. Native gives the biggest startup and memory gains but demands closed-world compatibility, long builds, different tooling and ongoing metadata work, while the AOT cache keeps full JVM behaviour and only needs a training run. The right framing is a portfolio: the AOT cache as the low-risk default, native where measurements prove it pays, and review points tied to JDK releases so the company never makes an irreversible bet.

What to say in the interviewAbout 100 seconds aloud

Open with

I would reframe this from a single bet into a portfolio. Native images give the best startup and memory today, but they come with a closed-world model, so every library that uses reflection or proxies needs reachability metadata, builds take minutes and lots of memory, peak throughput can trail the JIT, and our Java agents for observability do not work in them.

Then, if they want more

The JDK AOT cache from Project Leyden, which started in JDK 24 and grew in JDK 25, keeps full JVM behaviour and only needs a training run in the pipeline. Its gains are smaller today, but they grow with every release and the risk is close to zero.

So my recommendation would be to make the AOT cache the default in our golden path, and to support native images as an option for workloads where measurements show a clear payoff, like scale-to-zero services, short-lived jobs or services with hundreds of replicas where memory dominates cost.

Teams that choose native would own their metadata, and the platform would give them templates and CI capacity. I would not issue an irreversible mandate either way.

I would set review points at each JDK LTS release, look at fleet data such as startup, memory, cost per request and incidents caused by native builds, and write down in advance what result would make us widen or shrink the native footprint. That way leadership gets savings now and keeps both options open as the landscape changes.

About this answer

Last updated
12 November 2026
Versions it names
Java 25, Java 24
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Leadership asks whether the company should bet on GraalVM native images or on the JDK's...": https://scrivio-interview-library.netlify.app/spring-boot/native-and-aot/dfd9efa2e0/