Java / GraalVM Interview questions
How does the native-image build process work end-to-end?
The build pipeline can be thought of as several sequential phases.
flowchart TD A[Classpath + entry point] --> B[Points-to static analysis] B --> C[Build-time class initialization] C --> D[Universe/heap snapshot creation] D --> E[AOT compilation via Graal compiler] E --> F[Linking with Substrate VM runtime] F --> G[Native executable]
- Points-to analysis starts from the main method and iteratively discovers every reachable class, method, and field, folding in whatever reflection/resource config was supplied.
- Class initialization runs eagerly for classes marked build-time, baking their state into an initial heap snapshot.
- AOT compilation then compiles all reachable methods using the Graal compiler, this time working in ahead-of-time mode instead of JIT mode.
- Linking combines the compiled code with the Substrate VM runtime (GC, threading) into one native binary.
Any reflective call, resource load, or dynamic proxy that the points-to analysis can't statically resolve either needs explicit configuration or causes the build to fail (or fall back) depending on the flags used.
More Related questions...