Repository navigation
Description
Background
Grails 8 now has a native-image build path: #16094 added processAot wiring, cooperation with org.graalvm.buildtools.native, and the GenerateNativeMetadataTask / TraceNativeMetadataTask machinery, and #16102 moved i18n onto Spring Boot's MessageSource with an I18nRuntimeHintsProcessor that registers resource hints for the effective spring.messages.basename.
What neither PR established is a build that actually compiles a native binary and runs it. Today:
- nothing in the repository invokes
nativeCompile,nativeRunornativeTest; - no CI workflow provisions GraalVM or mentions native-image;
grails-test-examples/aotverifiesprocessAotoutput and a JVM startup check, both of which run on a normal JDK.
So every native-image claim in the framework currently rests on JVM-level AOT processing plus reasoning about the metadata, rather than on a binary that was built and exercised. That is a reasonable place to have landed the feature work, but it leaves a gap worth closing deliberately.
Proposal
Add a native-image verification target — most likely under end-to-end/, since it already consumes published artifacts — that builds a real GraalVM binary from a Grails application and asserts runtime behaviour that only a native image can falsify.
Suggested first assertions, ordered by how likely they are to catch something:
- Plugin message bundles resolve. A namespaced plugin bundle (for example
spring-security-core_fr.properties) resolving in the binary. This is the case Spring Boot's ownMessageSourceRuntimeHintsdoes not cover — it registers two hardcodedmessages*patterns and derives nothing from the configured base names — so ifI18nRuntimeHintsProcessoris wrong, plugin messages resolve on the JVM and silently vanish in native. - A base name the application configured itself resolves, e.g.
spring.messages.basename: config/i18n/custom, covering the dot-to-slash path conversion. - The i18n descriptor is readable, since base-name discovery reads
META-INF/grails/i18n.propertiesthrough an exact-nameClassLoader.getResourceslookup at runtime. - Whatever equivalent assertions the AOT cache and native metadata work from Make Grails applications processable by Spring AOT (Leyden AOT Cache + GraalVM Native Image Support) #16094 would want.
Open question worth settling with the test
I18nRuntimeHintsProcessor uses the same hint API Spring Boot uses. Boot's MessageSourceRuntimeHints calls registerPattern (verified in spring-boot-autoconfigure 4.1.0: it references registerPattern, messages.properties and messages_*.properties, and never registerResourceBundle), and this processor does the same. The difference is coverage, not mechanism: Boot registers two hardcoded messages* patterns and derives nothing from the configured base names, whereas this one generates patterns from the effective spring.messages.basename, which is what brings namespaced plugin bundles along.
The open question is only whether the more precise hints.resources().registerResourceBundle(...) would also work. It exists and is the more obvious API for message bundles, yet Boot does not use it. The likely reason is that it serialises to a {"bundle": ...} entry, which GraalVM resolves against the image's included locale set, so non-default locales could drop out — but that is inferred from reading the serialisation code, not documented by Boot or confirmed against a binary. A native test would settle it. If registerResourceBundle turns out to be safe, the hints could become more precise.
Notes
- This is framework-wide infrastructure, not specific to i18n: a native job would serve the AOT cache work, GORM, GSP and anything else that ships hints.
- Cost is the main design question. A full
nativeCompileis minutes of CPU and needs a GraalVM toolchain, so it probably belongs on a scheduled or opt-in workflow rather than every PR.
Raised from review discussion on #16102.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
codeconsole commentedon Sep 11, 2026
Native image is blocked upstream, on Groovy rather than on hints
#16180 adds the module this issue asks for, and @matrei built and ran the binary — the half nobody had done. The result is that the open question above cannot be settled yet, for reasons that have nothing to do with
I18nRuntimeHintsProcessor.Dynamic Groovy does not run in a native image on any released Groovy, whichever way it is compiled:
CallSiteArrayand define call-site classes as they run, which an image forbids:UnsupportedFeatureError: Tried to define classIndyInterface's bootstrap method without its<clinit>having run, so astatic finalhandle is still null:BootstrapMethodError: NullPointerExceptionatIndyInterface.makeBootHandleReproduced by @matrei with a ten-line Groovy hello-world — no Spring, no Grails, metadata from the tracing agent — against both 5.1.2 and 4.0.27, so it is not a Grails metadata gap. Registering every
IndyInterfacemethod for reflection changes nothing,--exact-reachability-metadatareports no missing registration, and--initialize-at-build-timefails on image-heap objects.Two upstream blockers, then:
groovy.version5.1.2, whoseIndyInterfacecarries neitheraotDispatchnor theensureInitializedguard that 6.0.0-RC-1 added. Related: GROOVY-12227, and in the unreleased 6.0.0-RC-2 GROOVY-12364/12365/12366 (reachability metadata andnative-image.propertiesshipped in the groovy jar).IndyInterface.invalidateSwitchPoints(), which Groovy 4+ removed, sonativeCompilefails during "Initializing" on the GraalVM 21 line. Fixed in the 25 line.There is a third, inside Grails:
CompilePlugindefaultsgrailsIndytofalsefor published artifacts, because Groovy 5's indy default is a large runtime regression for dynamic Groovy (#15293). So a released Grails 8 could not produce an image even once Groovy and GraalVM are fixed. Its own comment already records Grails 9 / Groovy 6 as where that can flip — the same boundary as blocker 1, which is convenient, but it should be a deliberate decision rather than a coincidence.What this means for the issue
checkand the native half behind-PnativeTests, documented as not passing. It is written so it starts passing when the above land rather than having to be authored then.registerPatternvsregisterResourceBundlequestion stays open. It needs a binary to settle, and no binary is buildable from a released toolchain today.configureNativeImageand the upgrade guide currently imply native image is a Grails 8 capability. On Groovy 5 it is not one, for any application. Either that wiring is documented as forward-looking, or the claim moves to the release where it is true.Cheapest way to learn when the gap closes, per @matrei: the snapshot canary workflow already rebuilds Grails against a Groovy branch by rewriting
groovy.version. Runningnative-i18nin that job on GraalVM 25, once 6.0.0-RC-2 ships, would tell us without anyone having to re-derive this.