Java / GraalVM Interview questions
Explain the purpose of resource-config.json in native image?
Because Native Image's static analysis can't know which files your application will load via Class.getResourceAsStream or similar calls with a runtime-computed path, any resource that needs to be bundled into the final executable must be listed explicitly.
{ "resources": { "includes": [ { "pattern": "\\Qconfig/app.properties\\E" }, { "pattern": "templates/.*\\.html$" } ] } }
Placed at META-INF/native-image/resource-config.json, this tells the builder which classpath resources to embed directly into the executable's data section, since there's no external classpath to read from at run time the way there is on a normal JVM.
Like reflection config, this file is most reliably produced by running the app under the native-image-agent tracing agent rather than writing regex patterns by hand.
More Related questions...