GROOVY-10687: complete NestMembers after class generation instead of … - #2734
Merged
Merged
Conversation
…reordering classgen Closure and anonymous inner classes materialize while bytecode is being generated, so a nest host emitted in normal order could not list them in its NestMembers attribute. The previous approach sorted nest hosts to the back of the classgen queue, which broke the supers-before-subclasses invariant relied on by ClassCompletionVerifier (GROOVY-11753, GROOVY-12188) and still could not see a host's own nested closures, requiring name prediction (GROOVY-11780). No ordering satisfies both constraints once a nest member extends its own host. Instead, restore plain hierarchy-order sorting and complete each nest host's NestMembers in a post-generation pass: once all of a module's classes are generated, the host's inner class list is complete, so its bytes are rewritten with the exact member set. GroovyClassLoader defines classes from the post-processed bytes. This removes the reordering, the closure-detection walk, and the member-name prediction, and is unaffected by whether a closure ultimately produces a class (GEP-27 closure packing).
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2734 +/- ##
==================================================
- Coverage 69.2732% 69.2719% -0.0012%
+ Complexity 34769 34766 -3
==================================================
Files 1542 1542
Lines 130456 130441 -15
Branches 23786 23786
==================================================
- Hits 90371 90359 -12
+ Misses 31962 31961 -1
+ Partials 8123 8121 -2
🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: cc48a7a Learn more about TestLens at testlens.app. |
eric-milles
approved these changes
Jul 24, 2026
eric-milles
left a comment
Member
There was a problem hiding this comment.
I don't check the nest member attributes that much, but all my tests seem to be holding up fine.
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.
…reordering classgen
Closure and anonymous inner classes materialize while bytecode is being generated, so a nest host emitted in normal order could not list them in its NestMembers attribute. The previous approach sorted nest hosts to the back of the classgen queue, which broke the supers-before-subclasses invariant relied on by ClassCompletionVerifier (GROOVY-11753, GROOVY-12188) and still could not see a host's own nested closures, requiring name prediction (GROOVY-11780). No ordering satisfies both constraints once a nest member extends its own host.
Instead, restore plain hierarchy-order sorting and complete each nest host's NestMembers in a post-generation pass: once all of a module's classes are generated, the host's inner class list is complete, so its bytes are rewritten with the exact member set. GroovyClassLoader defines classes from the post-processed bytes. This removes the reordering, the closure-detection walk, and the member-name prediction, and is unaffected by whether a closure ultimately produces a class (GEP-27 closure packing).