Java / GraalVM Interview questions
How do you troubleshoot missing reflection metadata errors during native image build?
These errors typically surface as either a build-time warning about an unreachable class, or a runtime ClassNotFoundException/NoSuchMethodException in the finished binary.
- Reproduce the failing code path on a plain JVM with the tracing agent attached:
-agentlib:native-image-agent=config-merge-dir=META-INF/native-image(using merge mode so you don't overwrite existing entries). - Exercise every relevant code path, including error/edge cases, since the agent only records what actually executes.
- Diff the merged config against version control to see exactly what new entries were captured.
- If the missing class belongs to a well-known library, check the GraalVM Reachability Metadata Repository before hand-writing config.
- Re-run
native-imagewith-H:+PrintClassInitializationor verbose analysis output if the failure is initialization-order related rather than pure reflection.
Avoid the temptation to blanket-list "allDeclaredMethods": true across huge packages "just in case" - it balloons build time and image size while masking the specific configuration gap you actually need to find.
More Related questions...