Skip to content

feat: enable Groovy invokedynamic by default on Grails 9 - #16165

Merged
jdaugherty merged 24 commits into
9.0.xfrom
feat/indy-default-groovy6
Oct 16, 2026
Merged

jdaugherty merged 24 commits into
9.0.xfrom
feat/indy-default-groovy6

Conversation

@jamesfredley

@jamesfredley jamesfredley commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Enable Groovy invokedynamic by default on Grails 9.

Grails 7 disabled indy because Groovy 4 paid a 2-8x penalty (#15293). Grails 9 is on Groovy 6. Earlier A/B work on perf/indy-vs-callsite-g6 showed:

  • microbenchmarks: positive for indy
  • app-level HTTP benches: flat to slightly negative

That is still a large improvement over the old 2-8x hit. This PR flips the default so generated apps and published framework modules match Groovy 6's preferred dispatch. The performance label is set so CI JMH can measure this default against 9.0.x.

What changed

  • grails { indy } is now unset by default, and the Grails Gradle plugin applies it to GroovyCompile tasks only when the application sets it. Gradle passes no indy option otherwise, so the Groovy compiler keeps its own default, which is invokedynamic on Groovy 6. Grails 8 keeps overriding it with false (Groovy - invoke dynamic performance problems #15293).
  • Opt out: grails { indy = false } plus implementation 'org.apache.groovy:groovy-callsite', which the Grails BOM manages. Grails no longer carries the module: grails-common's api dependency on it is removed, so an application that keeps the default never ships it. The Groovy compiler names the module when it is missing.
  • An application that applies GraalVM's native image plugin keeps the indy convention set to true, and the build fails with the reason if it sets grails { indy = false }: a classic call site defines a class at run time, which a native image cannot do. Each Groovy compile task of such a project also checks its own indy option as it starts, so a build script that sets it to false on the task after the plugin has configured it fails the same way instead of building a broken image.
  • The security functional specs keep their Spock with() blocks, the functional test app's HackController keeps session[name], and the security taglib keeps its Map-coerced FilterChain. The earlier rewrites worked around Spock 2.4's Groovy 5 build on Groovy 6; with Spock 2.5-groovy-6.0 the with() conditions dispatch correctly when compiled with indy, and the misc test configuration's specs and SecurityTagLibUnitSpec pass with the original code compiled with indy. All of those files are identical to 9.0.x again.
  • CI's -PgrailsIndy=false lane gets the module from CompilePlugin, which declares groovy-callsite on every source set of every module of the invoked build (not the included builds, whose Gradle plugins run on Gradle's own Groovy): a module compiled with invokedynamic may still compile or run against a classic-compiled one in that lane, such as a test module against a plugin module's test fixtures, or the GSON view compiler against a plugin's classes. The version is read from dependencies.gradle's map, applied to the root project once in that lane, because the ast source set the Grails plugin gives every plugin project has no platform on its configurations. The spring-security/ui/common module now applies the compile convention plugin like every other Groovy-compiling module. The Forge CLI fixtures' own declaration is gone.
  • The Forge builds that run with -PgrailsIndy=false publish a classic-compiled framework to build/local-maven for the applications the specs generate. Those applications now declare the module as any application consuming a classic-compiled library must: the Forge build names grails-forge/gradle/classic-framework.init.gradle in a system property of the test tasks, and both harnesses run every generated build with it (GeneratedBuild in the CLI module's test fixtures). The generated build files stay as Forge writes them; a published Grails is compiled with invokedynamic, so a real application never needs this.
  • A library compiled with classic call sites needs the module whatever the application's setting, because Groovy 6 loads such a class only with it. testcontainers-spock (1.x and 2.x) is one; Spock 2.5, Geb 8 and Asset Pipeline 5.2.2 are not. The four modules that test with it declare testRuntimeOnly 'org.apache.groovy:groovy-callsite' next to it, and the docs and skills describe the case.
  • Published framework modules already compile with invokedynamic on 9.0.x (CompilePlugin, a963c8b), so this PR no longer changes CompilePlugin.
  • whatsNew.adoc, the 9.0 upgrade guide and the AOT deployment chapter document the change, the opt-out and the native-image rule.
  • The grails-developer skill tells agents to remove the indy settings and groovy-callsite dependency a Grails 7 or 8 build carried, and offers classic call sites as the alternative; the gradle-developer skill and AGENTS.md record that groovy-callsite is never a framework dependency and how the -PgrailsIndy=false lanes get it.

Not in this PR

The full app-bench harness from perf/indy-vs-callsite-g6 is not copied here. That branch is 3.7k lines and stale vs current 9.0.x. CI JMH via the performance label is the measurement path.

Test plan

  • GrailsExtensionSpec unset default and opt-out; GrailsIndySpec (TestKit) unset, false and true on every compile task, and the compiled bytecode's call sites for each (invokedynamic when unset or true, classic when false); GrailsNativeImageDefaultsSpec keeps an image's compile tasks indy, accepts an explicit true, fails grails { indy = false } at evaluation, and fails a compile task set to classic call sites after the plugin configured it
  • CI performance JMH vs 9.0.x

Grails 7 turned indy off because Groovy 4 paid a 2-8x penalty (#15293).
Grails 9 is on Groovy 6, where microbenchmarks were already positive and
app-level results were flat to slightly negative. Make indy the default
so generated apps match Groovy 6's preferred dispatch.

Opt out with grails { indy = false }. Non-indy still needs groovy-callsite,
which the BOM already manages. Framework modules honor -PgrailsIndy so CI
and JMH can still A/B both modes.

Assisted-by: claude-code:claude-opus-5
Copilot AI lite review requested due to automatic review settings August 18, 2026 17:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR flips the default Groovy invokedynamic (“indy”) setting to enabled for Grails 9 builds, aligning generated applications with Groovy 6’s preferred dynamic dispatch mode while preserving an opt-out path and CI/framework-module toggling.

Changes:

  • Set the grails { indy } convention default to true and update plugin logging accordingly.
  • Add build-logic support for -PgrailsIndy to control indy in framework modules, including adding org.apache.groovy:groovy-callsite when indy is forced off.
  • Add/extend tests and documentation covering the new default and the opt-out configuration.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
grails-gradle/plugins/src/test/groovy/org/grails/gradle/plugin/core/GrailsExtensionSpec.groovy Adds tests asserting indy default-on and opt-out behavior in the Gradle extension.
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy Changes indy default handling to enabled and updates informational logging.
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy Sets the indy convention default to true and updates associated Javadoc.
grails-doc/src/en/guide/introduction/whatsNew.adoc Documents indy being enabled by default and how to disable it.
build-logic/plugins/src/test/groovy/org/apache/grails/buildsrc/CompilePluginIndySpec.groovy Adds coverage for -PgrailsIndy behavior in framework-module compilation configuration.
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy Honors -PgrailsIndy for framework modules and adds groovy-callsite when indy is disabled.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

JMH Shard Pairing

Complete shard pairs used: 2

JMH Benchmark Report

Regressions: 0
Improvements: 1
Runner health: worst ruler deviation: 5.2% in shard-b.json (MemoryRulerBenchmark.allocateAndCopyArray (mode=avgt))
Ruler benchmarks are excluded from verdicts and group summaries; runner health is a stability check, not a calibration factor.
Ruler movements: shard-a.json: CpuRulerBenchmark.integerArithmetic (mode=avgt): 1.00x, shard-a.json: MemoryRulerBenchmark.allocateAndCopyArray (mode=avgt): 1.00x, shard-b.json: CpuRulerBenchmark.integerArithmetic (mode=avgt): 0.99x, shard-b.json: MemoryRulerBenchmark.allocateAndCopyArray (mode=avgt): 0.95x

Warning: The runner was unstable BETWEEN the two halves of the A/B run. Treat results as unreliable. Runner health is a stability check, not a calibration factor.

Group geometric means are descriptive only, not verdicts.

Group Descriptive geomean speedup n
controllers 1.03x 6
databinding 1.01x 2
gsp 1.01x 2
interceptors 1.03x 6
urlmappings 0.97x 4
views 1.08x 2
web 0.99x 12
Per-benchmark results
Benchmark Base score Head score Speedup Verdict Allocation delta (ADVISORY)
views.ViewTemplateRenderingBenchmark.renderMarkupTemplate (mode=avgt) 680 ns/op 599 ns/op 1.14x IMPROVED -96 B/op (-10.0%)
controllers.ControllerActionBenchmark.commandObjectAction (mode=avgt) 4.98e+04 ns/op 4.86e+04 ns/op 1.02x no clear change -302 B/op (-0.4%)
controllers.ControllerActionBenchmark.plainAction (mode=avgt) 51.8 ns/op 51.9 ns/op 1.00x no clear change ~0 B/op
controllers.ControllerActionBenchmark.restrictedAction (mode=avgt) 67.6 ns/op 65.2 ns/op 1.04x no clear change ~0 B/op
controllers.ControllerMappingCollectionBenchmark.fourCandidates (mode=avgt) 905 ns/op 898 ns/op 1.01x no clear change -6 B/op (-0.4%)
controllers.ControllerMappingCollectionBenchmark.oneCandidate (mode=avgt) 335 ns/op 313 ns/op 1.07x no clear change ~0 B/op
controllers.ControllerMappingCollectionBenchmark.twoCandidates (mode=avgt) 460 ns/op 450 ns/op 1.02x no clear change ~0 B/op
databinding.SimpleDataBinderBenchmark.bindFlatMap (mode=avgt) 6.85e+03 ns/op 6.81e+03 ns/op 1.01x no clear change ~0 B/op
databinding.SimpleDataBinderBenchmark.bindMapWithTypeConversion (mode=avgt) 7.21e+03 ns/op 7.05e+03 ns/op 1.02x no clear change +90 B/op (+2.3%)
gsp.GroovyPageParserBenchmark.parseSmallTemplate (mode=avgt) 9.73e+03 ns/op 9.49e+03 ns/op 1.03x no clear change +26 B/op (+0.0%)
gsp.GroovyPageParserBenchmark.parseTemplateWithTagsAndExpressions (mode=avgt) 4.25e+04 ns/op 4.24e+04 ns/op 1.00x no clear change +14 B/op (+0.0%)
interceptors.InterceptorChainBenchmark.oneInterceptorNoOpRegistry (mode=avgt) 77.3 ns/op 76.2 ns/op 1.01x no clear change ~0 B/op
interceptors.InterceptorChainBenchmark.oneInterceptorObservingRegistry (mode=avgt) 463 ns/op 441 ns/op 1.05x no clear change ~0 B/op
interceptors.InterceptorChainBenchmark.threeInterceptorsNoOpRegistry (mode=avgt) 649 ns/op 648 ns/op 1.00x no clear change +162 B/op (+54.7%) candidate
interceptors.InterceptorChainBenchmark.threeInterceptorsObservingRegistry (mode=avgt) 1.84e+03 ns/op 1.8e+03 ns/op 1.02x no clear change -162 B/op (-3.1%)
interceptors.UrlMappingMatcherBenchmark.matchUriPattern (mode=avgt) 133 ns/op 122 ns/op 1.09x no clear change -24 B/op (-12.0%)
interceptors.UrlMappingMatcherBenchmark.rejectNonMatchingUriPattern (mode=avgt) 36.9 ns/op 37.2 ns/op 0.99x no clear change ~0 B/op
ruler.CpuRulerBenchmark.integerArithmetic (mode=avgt) 1.7e+03 ns/op 1.71e+03 ns/op 0.99x ruler - excluded ~0 B/op
ruler.MemoryRulerBenchmark.allocateAndCopyArray (mode=avgt) 625 ns/op 647 ns/op 0.97x ruler - excluded ~0 B/op
urlmappings.UrlMappingsBenchmark.matchColdCatchAllFallThrough (mode=avgt) 1.58e+03 ns/op 1.59e+03 ns/op 0.99x no clear change -10 B/op (-0.5%)
urlmappings.UrlMappingsBenchmark.matchColdVariedKeys (mode=avgt) 1.38e+03 ns/op 1.39e+03 ns/op 0.99x no clear change +6 B/op (+0.4%)
urlmappings.UrlMappingsBenchmark.matchWarmCache (mode=avgt) 4.81 ns/op 5.09 ns/op 0.94x no clear change ~0 B/op
urlmappings.UrlMappingsBenchmark.reverseMappingAndCreateRelativeUrl (mode=avgt) 111 ns/op 114 ns/op 0.97x no clear change ~0 B/op
views.ViewTemplateRenderingBenchmark.renderJsonTemplate (mode=avgt) 6.12e+03 ns/op 5.97e+03 ns/op 1.03x no clear change -134 B/op (-0.6%)
web.GrailsWebRequestBenchmark.construct (mode=avgt) 34 ns/op 34.4 ns/op 0.99x no clear change ~0 B/op
web.GrailsWebRequestBenchmark.paramsCached (mode=avgt) 0.618 ns/op 0.631 ns/op 0.98x no clear change ~0 B/op
web.GrailsWebRequestBenchmark.paramsOnFreshRequest (mode=avgt) 956 ns/op 983 ns/op 0.97x no clear change ~0 B/op
web.GrailsWebRequestBenchmark.paramsRebuilt (mode=avgt) 400 ns/op 430 ns/op 0.93x no clear change ~0 B/op
web.MultipartResolutionBenchmark.resolveMultipartBehindTwoWrappers (mode=avgt) 4.51 ns/op 4.64 ns/op 0.97x no clear change ~0 B/op
web.MultipartResolutionBenchmark.resolveMultipartByAttribute (mode=avgt) 3.32 ns/op 3.35 ns/op 0.99x no clear change ~0 B/op
web.MultipartResolutionBenchmark.resolvePlainBehindTwoWrappers (mode=avgt) 28.3 ns/op 28.7 ns/op 0.99x no clear change ~0 B/op
web.MultipartResolutionBenchmark.resolvePlain (mode=avgt) 1.94 ns/op 2.11 ns/op 0.92x no clear change ~0 B/op
web.RequestPropertyAccessBenchmark.groovyAttributeCall (mode=avgt) 2.56 ns/op 2.57 ns/op 1.00x no clear change ~0 B/op
web.RequestPropertyAccessBenchmark.groovyGetterBackedProperty (mode=avgt) 0.808 ns/op 0.803 ns/op 1.01x no clear change ~0 B/op
web.RequestPropertyAccessBenchmark.groovyUnknownProperty (mode=avgt) 143 ns/op 140 ns/op 1.03x no clear change ~0 B/op
web.RequestPropertyAccessBenchmark.javaGetAttribute (mode=avgt) 2.72 ns/op 2.56 ns/op 1.07x no clear change ~0 B/op

@codecov

codecov Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.50000% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.9973%. Comparing base (d989ce9) to head (144c116).
⚠️ Report is 32 commits behind head on 9.0.x.

Files with missing lines Patch % Lines
...rails/gradle/plugin/core/GrailsGradlePlugin.groovy 8.6956% 21 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##                9.0.x     #16165        +/-   ##
==================================================
+ Coverage     60.9935%   60.9973%   +0.0038%     
+ Complexity      26643      26637         -6     
==================================================
  Files            2249       2249                
  Lines          111561     111577        +16     
  Branches        20207      20224        +17     
==================================================
+ Hits            68045      68059        +14     
- Misses          34532      34553        +21     
+ Partials         8984       8965        -19     
Files with missing lines Coverage Δ
...g/grails/gradle/plugin/core/GrailsExtension.groovy 58.9286% <100.0000%> (+3.5714%) ⬆️
...rails/gradle/plugin/core/GrailsGradlePlugin.groovy 29.0114% <8.6956%> (-0.6059%) ⬇️

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

-PgrailsIndy=false is how CI compiles applications without indy. Wiring
that property through CompilePlugin forced every framework module onto
classic callsites and added org.apache.groovy:groovy-callsite with no
version, so those jobs failed with "Could not find groovy-callsite:.".

Leave framework compilation on Groovy's default. App indy remains
controlled by grails { indy }. Clarify the docs so default-on does not
read like a required setting.

Assisted-by: claude-code:claude-opus-5
@codeconsole

Copy link
Copy Markdown
Contributor

Indy Whiplash?

I agree with this change, but I wonder if we should consider turning indy on in the final release of 8? I think it is counter intuitive to go against Groovy defaults and turn it opposite to normal compiler behavior. At the very least we should consider not changing downstream plugin behavior and perhaps enforce plugins indy true?

The following should be fully understood prior to 8.0.0:

  1. Benchmark for an app with Grails compiled indy false, plugins false, and app false. (Current 8 defaults)
  2. Benchmark for an app with Grails compiled indy true, plugins false, and app true.
  3. Benchmark for an app with Grails compiled indy true, plugins true, and app false. (Unknown?)
  4. Benchmark for an app with Grails compiled indy true, plugins true, and app true (default Groovy behavior)

Current state of Grails 8

indy OFF (29): grails-cache, grails-fields, grails-geb, grails-mail, grails-redis, grails-scaffolding, grails-views-gson, grails-views-markup, grails-undertow/plugin, grails-gsp/{plugin,grails-layout,grails-sitemesh3}, grails-data-hibernate5/{grails-plugin,dbmigration}, grails-data-hibernate7/{grails-plugin,dbmigration}, grails-data-mongodb/grails-plugin, grails-data-graphql/plugin, all 11 grails-spring-security/* plugin modules.

indy ON (17, Groovy 5 default): grails-core, grails-controllers, grails-domain-class, grails-url-mappings, grails-interceptors, grails-services, grails-databinding, grails-converters, grails-codecs, grails-mimetypes, grails-i18n, grails-datasource, grails-micronaut, grails-rest-transforms, grails-async/plugin, grails-events/plugin, grails-data-neo4j/grails-plugin.

MiscSpec is identical to 8.0.x and passed on 9.0.x when the plugin
defaulted to indy=false. With indy on by default, Map-as-FilterChain
and session[name] are fragile Groovy dispatch. Use a real FilterChain
and HttpSession.getAttribute instead.

Assisted-by: claude-code:claude-opus-5
@jamesfredley

Copy link
Copy Markdown
Contributor Author

@codeconsole only holdup is Groovy 5 indy is not as fast as Groovy 6 indy.

MiscSpec failed only when the security plugin compiled with indy on.
The session dump already contained Username=admin. with(auth) {
contains(...) } does not dispatch to String.contains under Groovy 6
indy. Direct pageSource.contains already passed. Call contains on the
string instead and snapshot pageSource once per assertion block.

Assisted-by: claude-code:claude-opus-5
The same dispatch bug as MiscSpec. ACL and UI functional specs call
with(pageSource) { contains(...) }, which does not hit String.contains
when compiled with invokedynamic. Use pageSource.contains instead.

Assisted-by: claude-code:claude-opus-5
UserSimpleSpec failed because with(page.rolesTab) { hasEnabledRole(...) }
dispatched to Geb DefaultNavigator under Groovy 6 invokedynamic. Call
the tab methods on page.rolesTab instead.

Assisted-by: claude-code:claude-opus-5
@jamesfredley

Copy link
Copy Markdown
Contributor Author

App-level indy vs callsite (local A/B)

Ran the existing perf/indy-vs-callsite-g6 HTTP harness on this PR's tree (ccce1baf53 plus an uncommitted harness overlay). Same SHA, -PgrailsIndy=false (base) vs -PgrailsIndy=true (head).

Machine: Windows, JDK 21, warmup 80 / samples 300 / forks 2.

App Endpoint noindy indy Speedup Verdict
latency GET /fast/ping 4.42 ms/op 4.53 ms/op 0.98x no clear change
app1 GET /interceptorDemo/one 9.20 ms/op 9.27 ms/op 0.99x no clear change
gsp-layout GET /demo/renderText n/a n/a — skipped: module has no grails-testing-support-http-client dep

This matches the earlier story: app-level is flat to slightly negative, not the old 2-8x Groovy 4 penalty.

A follow-up 9.0.x PR will land the harness (including the missing gsp-layout dep) and teach benchmark.yml to run this A/B on the performance label.

@jdaugherty jdaugherty left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove teh mass test changes that removed the with usage in tests?

@jamesfredley

jamesfredley commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

This will be reworked once #16178 and #16169 are merged.

@jamesfredley jamesfredley mentioned this pull request Sep 4, 2026
14 of 16 tasks
Take #16178's CompilePlugin -PgrailsIndy toggle and flip the default
to true so Grails 9 / Groovy 6 framework modules match app-level
grails { indy } (already default-on). CI can still pass
-PgrailsIndy=false.

Assisted-by: Sisyphus:grok-4.6
@jamesfredley

Copy link
Copy Markdown
Contributor Author

Brought in #16178 via the 8.0.x -> 8.1.x -> 9.0.x merge-up (#16318, #16319).

CompilePlugin now uses the same -PgrailsIndy toggle as Grails 8, with the default flipped to true so Grails 9 / Groovy 6 framework modules match app-level grails { indy } (already default-on here). CI can still pass -PgrailsIndy=false.

codeconsole added a commit to codeconsole/grails-core that referenced this pull request Oct 13, 2026
9.0.x is on Groovy 6.0.0, which carries the AOT link mode and ships its
own native-image configuration, not 6.0.0-beta-2. Invokedynamic is on
for the library modules only: the plugin modules, including grails-gsp,
grails-sitemesh3 and grails-cache from the web starter, still follow the
Grails Gradle plugin's default until apache#16165 changes it.
CompilePlugin and its spec take 9.0.x's version: since a963c8b the
library modules compile with invokedynamic on regardless of -PgrailsIndy,
because they do not carry groovy-callsite, which already covers this
branch's "default on for published modules" change. gradle.properties
takes 9.0.x's 3G daemon and drops the Spock version-check opt-out that
the move to Spock 2.5-groovy-6.0 retired.
…ts it

Gradle passes no indy option to the Groovy compiler unless a build sets
one, and the compiler then uses its own default, which is invokedynamic
on Groovy 5 and 6. Grails 7 and 8 have to override that with false for
performance (#15293); Grails 9 does not, so instead of defaulting
grails { indy } to true and writing it onto every GroovyCompile task, the
property is now unset by default and the plugin only applies a value the
application set. That stops the plugin from replacing an indy option a
build script puts on its own compile task, and the native-image hook no
longer needs to set an indy convention, since an image's need for
invokedynamic is the compiler's default.

GrailsNativeImageDefaultsSpec hard-coded the Grails 8 default of false
for an application without an image; it and its fixtures now check that
no indy option is set on the compile task. GrailsIndySpec covers the
unset default and both explicit values through a TestKit build. What's
New describes the change without the internal build details, and the
9.0 upgrade guide notes it for applications coming from Grails 8.
Reverts ccce1ba, 0017bc6 and 782b00f, which replaced Spock
with(target) { ... } blocks with explicit target.method() conditions in 21
security functional specs because a call such as contains(...) inside
with(pageSource) did not reach String.contains when compiled with
invokedynamic.

That was Spock 2.4's Groovy 5 build running on Groovy 6. 9.0.x now uses
Spock 2.5-groovy-6.0, and the patterns pass when compiled with indy: a
probe GebSpec ran with(pageSource) { contains(..); !contains(..) } and
with(page) { username.text == ..; !accountLocked.checked }, and a plain
Specification with its own truthy contains(String) ran the same negative
condition, which would fail if the call reached anything but the String.
The specs are identical to 9.0.x again.
…ndy off

A native image needs invokedynamic: a classic call site defines a class
at run time, which an image cannot do. Leaving indy at the compiler's
default removed the native-image hook's indy convention, so an
application that set grails { indy = false } built an image that failed
on its first dynamic call.

The hook is back as it was, setting the convention to true when GraalVM's
plugin is applied, which also overrides a compile task a build script set
to classic call sites, since the plugin applies the extension's value to
every Groovy compile task. After evaluation it throws, with the reason, if
the application set grails { indy = false } itself.
GrailsNativeImageDefaultsSpec covers both, the deployment guide's AOT
chapter documents it, and the 9.0 upgrade note mentions it.
The native image guard read only the extension, so a build script that
set the indy compiler option to false on a compile task from its own
afterEvaluate, which runs after the plugin's, kept classic call sites and
built an image that failed on its first dynamic call. Each Groovy compile
task of a project that applies GraalVM's plugin now checks its own option
as it starts and fails with the reason; the fixture gains that late
override and a spec for it, plus a row for an explicit indy = true.

GrailsIndySpec now proves the premise from the bytecode: the fixture
compiles a dynamic class and the class file carries invokedynamic call
sites when indy is unset or true, and classic ones when it is false.

The comments on the groovy-callsite dependencies in grails-common and the
Forge CLI fixtures said Grails compiles without invokedynamic, which is no
longer so; they now name the opt-out and CI's -PgrailsIndy=false lane. The
upgrade note tells build logic that read grails.indy that it has no value
unless set, and the AOT chapter's wording matches what the guard does.
Reverts 2cbd651, which replaced session[name] in the security
functional test app's HackController with getAttribute, and the security
taglib's Map-coerced FilterChain with a nested class, on the same "fragile
dispatch under invokedynamic" diagnosis as the with() rewrites. Both
compile with invokedynamic now and both dispatch correctly: with the
original code restored, MiscSpec and DisableSpec of the misc test
configuration and SecurityTagLibUnitSpec pass, so the files are identical
to 9.0.x again. The nested class had also put a second copy of
GrailsWebInvocationPrivilegeEvaluator's dummy chain inside a taglib
artefact, where the artefact injectors sweep it.
grails-common declared org.apache.groovy:groovy-callsite as an api
dependency, so every Grails 9 application carried the module whether or
not it compiled classic call sites, which Grails 9 does not by default.
The dependency is gone: an application that sets grails { indy = false }
declares the module itself, at the version the Grails BOM manages, and
the Groovy compiler names it when it is missing. What's New, the 9.0
upgrade guide and the extension's javadoc say so.

CI's -PgrailsIndy=false lane compiles every source set of the Grails
plugin modules and example apps with classic call sites, so the shared
grails-extension-gradle-config script, which applies that flag, now
declares the module for each source set of such a project. The version
is read from the map in dependencies.gradle, applied to the root project
once in that lane as the build-logic builds apply it, because the ast
source set the Grails plugin gives every plugin project has no platform
on its configurations to supply one.
The Forge CLI test fixtures no longer need their own declaration: they
compile with invokedynamic like everything else.

The TestKit fixtures' Groovy sources that the previous commit's bytecode
and late-override features compile were left out of it; they are added.
…ites

The grails-developer skill gains a Groovy call sites section: Grails 9
compiles with invokedynamic and ships no groovy-callsite, so the default
is to remove the indy settings and the groovy-callsite dependency a
Grails 7 or 8 build carried, and classic call sites are offered as the
alternative: grails { indy = false } plus the dependency the application
declares itself, which a native image build refuses.

The gradle-developer skill records how this repository handles it: the
library modules always compile with invokedynamic, grails-common must not
declare groovy-callsite, the -PgrailsIndy=false lanes get the module from
grails-extension-gradle-config with the version read from
dependencies.gradle applied to the root, and Forge ignores the flag.
AGENTS.md states the dependency rule.
… testcontainers-spock

With groovy-callsite gone from grails-common, the -PgrailsIndy=false
lane failed in three ways. A test module compiled against a plugin
module's test fixtures, now classic, failed to compile; the GSON view
compiler, run with a classpath that no longer carried the module, failed
to load a plugin's classes; and the Hibernate 7 specs failed to load
TestcontainersExtension. The first two are the lane's: declaring the
module only in the projects that apply grails-extension-gradle-config
missed every other module that compiles or runs against them. The
declaration moves to CompilePlugin, which every Groovy-compiling module
applies now that the spring-security UI common module does too: in that
lane it adds the module to every source set of every module, through a
provider so the version is read once the build scripts have run, from
the map in dependencies.gradle applied to the root project. It does so
only in the build that was invoked: the property reaches the included
builds too, and the Groovy 6 module on the Grails Gradle plugins'
classpath, which runs on Gradle's own Groovy, broke configuration with a
VerifyError in grails.util.Environment. The extension script keeps only
the indy toggle. CompilePluginSpec covers the declaration and its absence.

The third is not the lane's. testcontainers-spock is compiled with
classic call sites, which Groovy 6 loads only with the module, whatever
the application's own setting; Spock, Geb and the Asset Pipeline
versions in use are not. The four modules that test with it declare the
module as testRuntimeOnly next to it. What's New, the 9.0 upgrade guide,
the developer and Gradle skills and AGENTS.md describe that case.
… only

The previous commit skipped every included build when declaring
groovy-callsite in the -PgrailsIndy=false lane, to keep the Groovy 6
module off the Grails Gradle plugins' classpath. That also skipped
grails-core when Forge builds it as an included build, so Forge's
classic lane failed to compile the GSON views as before. The skip now
names the two builds whose code runs inside Gradle, build-logic and
grails-gradle, by root project name; grails-core is injected wherever it
is built. CompilePluginSpec covers both names.
…e in the classic lane

The two Forge builds that run with -PgrailsIndy=false failed in the specs
that generate an application and build it. The property reaches the
included grails-core build, so the framework those applications consume
from build/local-maven is compiled with classic call sites, which Groovy
6 loads only with groovy-callsite; the generated application, compiled
with invokedynamic and without the module, could not load the
@Integration transform or the JSON view compiler. Until the module left
grails-common every application got it transitively.

A real application never meets a classic-compiled Grails, since a
published one is compiled with invokedynamic, so the generated build
files stay as Forge writes them. Instead, in that lane, the Forge build
names an init script in a system property of the test tasks that build
generated applications, and both harnesses run every generated build
with it. The script declares the module on every source set of the
generated project, as any application that depends on a library compiled
that way must. GeneratedBuild in the CLI module's test fixtures turns
the property into the arguments, and GeneratedBuildSpec covers it.
@testlens-app

This comment has been minimized.

}
gradleCommand.append(' --no-daemon -S ').append(command)
gradleCommand.append(' --no-daemon -S ')
GeneratedBuild.arguments().each { String argument -> gradleCommand.append(argument).append(' ') }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve the init-script path as a single process argument

When Forge runs with -PgrailsIndy=false, GeneratedBuild.arguments() contains the absolute checkout path to the init script. Joining it into this string loses its argument boundary: executeCommand() subsequently calls split(" ") before constructing ProcessBuilder. A checkout such as /work/Grails Sources/grails-core therefore passes /work/Grails as the init-script path and the remainder as another argument, so generated-app builds fail before executing their tasks. Please assemble and pass a List<String> through to ProcessBuilder, retaining the init-script path as one element; adding quotes to the string will not fix the existing split. A path-with-spaces regression case would cover this.

@jdaugherty
jdaugherty merged commit ebf174e into 9.0.x Oct 16, 2026
21 of 86 checks passed
@jdaugherty
jdaugherty deleted the feat/indy-default-groovy6 branch October 16, 2026 13:03
codeconsole added a commit to codeconsole/grails-core that referenced this pull request Oct 17, 2026
apache#16165 made invokedynamic the default for the framework's plugin modules
and for applications, so grails-gsp, grails-sitemesh3 and grails-cache are
no longer published with classic call sites.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants