Skip to content

Reference implementation: next steps for compact closures (GEP-27 Groovy 7)#2714

Draft
paulk-asert wants to merge 4 commits into
apache:masterfrom
paulk-asert:gep27spikeOpenClosure
Draft

Reference implementation: next steps for compact closures (GEP-27 Groovy 7)#2714
paulk-asert wants to merge 4 commits into
apache:masterfrom
paulk-asert:gep27spikeOpenClosure

Conversation

@paulk-asert

Copy link
Copy Markdown
Contributor

Groovy closures without generated classes: bodies become methods, and a single pluggable resolver replaces the owner/delegate/strategy machinery — behavior-identical to today.

…les and full MOP integration

Under @PackedClosures (dynamic trust path) or -Dgroovy.target.closure.pack=true under @CompileStatic (where the type checker PROVES delegate-independence), an eligible closure literal's body is hoisted into a synthetic private method on the enclosing class and the literal is replaced by a shared PackedClosure adapter — removing the per-closure generated class (and the nested $_closure1$_closure2 name explosion) while the value stays a real groovy.lang.Closure. Ineligible closures (escaping, delegate-dependent, default-param, nested-in-generated-function) keep their class exactly as today; opt-out via @PackedClosures(mode = DISABLED).
One branch to an out-of-line callGeneral keeps the hot lane small (the
argument-wrapping fallbacks allocate, so they leave the lane) and its
standalone compilation lean. Assessed against Grails-shaped packed
workloads (findAll/collect/groupBy pipelines, map-iteration validation):
no measurable in-situ effect -- per-dispatch cost is already invisible
under real body work -- and ~5-9% on the adverse non-capturing
microbenchmark rows with the capturing rows unchanged. Kept as lane
hygiene; further lane tuning is demonstrably not worth pursuing.
…ods, and a single pluggable resolver replaces the owner/delegate/strategy machinery — behavior-identical to today
@paulk-asert
paulk-asert marked this pull request as draft July 16, 2026 23:09
@testlens-app

testlens-app Bot commented Jul 16, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: adc6077
▶️ Tests: 4596 executed
⚪️ Checks: 23/23 completed


Learn more about TestLens at testlens.app.

@blackdrag blackdrag 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.

my comments are actually in the other PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants