Reference implementation: next steps for compact closures (GEP-27 Groovy 7)#2714
Draft
paulk-asert wants to merge 4 commits into
Draft
Reference implementation: next steps for compact closures (GEP-27 Groovy 7)#2714paulk-asert wants to merge 4 commits into
paulk-asert wants to merge 4 commits into
Conversation
…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.
…h opt-in default true)
…ods, and a single pluggable resolver replaces the owner/delegate/strategy machinery — behavior-identical to today
paulk-asert
marked this pull request as draft
July 16, 2026 23:09
✅ All tests passed ✅🏷️ Commit: adc6077 Learn more about TestLens at testlens.app. |
blackdrag
reviewed
Jul 17, 2026
blackdrag
left a comment
Contributor
There was a problem hiding this comment.
my comments are actually in the other PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groovy closures without generated classes: bodies become methods, and a single pluggable resolver replaces the owner/delegate/strategy machinery — behavior-identical to today.