Java / Micronaut Interview questions
How do you troubleshoot slow or failing GraalVM native image builds in Micronaut?
Start by reading the native-image build log carefully rather than guessing; most failures fall into a handful of recurring categories: missing reflection/resource configuration for a third-party library, unsupported dynamic class loading, or a dependency that simply isn't native-image-ready.
- Check reachability metadata first. If a third-party library isn't a Micronaut module, it may lack the GraalVM reachability metadata Micronaut relies on; check the GraalVM reachability metadata repository or the library's own docs before writing custom config by hand.
- Isolate the failing dependency by temporarily removing suspect libraries and rebuilding, narrowing down which one triggers the failure.
- Add targeted reflect-config.json/resource-config.json entries only for the specific classes that need runtime reflection, rather than broad blanket configuration that bloats the binary and hides real problems.
- Watch build memory and time separately. A build that's merely slow often just needs more heap allocated to the native-image process, while a build that fails outright is a configuration or compatibility problem, not a resource one.
- Test incrementally by building a minimal reproduction of the failure rather than iterating on the full application, since native-image build cycles are expensive.
Once past initial setup, most ongoing pain comes from adding a new dependency that wasn't vetted for native compatibility, so it's worth checking new libraries against this before assuming there's a Micronaut-specific bug.
More Related questions...