Part 30 · Further improvements

AOT and native images: optimize the deployment case

Prerequisites: 01-ecosystem

What moves from runtime into the build?

Application + config: build inputs; Spring AOT: analyze + generate assets; Native build: closed-world analysis; Native executable: runtime behavior; Artifact tests: real integrations. Connections: Application + config to Spring AOT (analyze); Spring AOT to Native build (generated support); Native build to Native executable (execute); Native executable to Artifact tests (verify)
Simplified native-image pipeline; ahead-of-time processing and compilation are distinct steps. [S58] [S14]

Goal & mental model verified

Native images compile under a closed-world assumption. Spring AOT analyzes application assembly ahead of runtime and generates supporting assets. Dynamic bean-graph changes and reflection/resource access can require different handling.

[S58] [S14]

Worked example · design exercise synthesis

A rarely invoked quote utility may benefit from reduced startup overhead. A long-running service may favor JVM JIT behavior; measure both against the actual deployment workload.

[S58] [S14]

Engineering decision synthesis

Evaluate native deployment when startup and footprint constrain the product. Accept build complexity and compatibility work only when the measured operational benefit matters.

[S58] [S14]

Pitfall & diagnosis synthesis

A successful JVM run does not prove native compatibility. Runtime configuration that changes which beans exist can conflict with build-time assembly assumptions.

[S58] [S14]

Improve & validate synthesis

Test the native artifact itself, including serialization, resources and integrations. Compare cold start, steady-state throughput, memory and build time under equivalent conditions.

[S58] [S14]
Keep this: Optimize the lifecycle that dominates your real cost.
Check yourself: Can native mode freely rebuild its bean graph from runtime properties?

No. AOT/closed-world constraints limit runtime changes to application assembly.

Sources & further reading

  1. [S14] HotSpot technology overview

    Oracle / OpenJDK · documentation · accessed 2026-10-09 · Java SE 25

    Supports: Interpreter and adaptive compilation; Garbage collection

    Read the linked section to validate the mechanism and its version-specific constraints.

  2. [S58] Native image constraints

    Spring project maintainers · documentation · accessed 2026-10-09 · Documentation retrieved 2026-10-09

    Supports: Closed-world assumption; AOT processing; Runtime bean graph constraints

    Read the linked section to validate the mechanism and its version-specific constraints.