Skip to content

GROOVY-10687: complete NestMembers after class generation instead of … - #2734

Merged
paulk-asert merged 1 commit into
apache:masterfrom
paulk-asert:groovy10687postpass
Jul 24, 2026
Merged

GROOVY-10687: complete NestMembers after class generation instead of …#2734
paulk-asert merged 1 commit into
apache:masterfrom
paulk-asert:groovy10687postpass

Conversation

@paulk-asert

Copy link
Copy Markdown
Contributor

…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).

…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-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.2719%. Comparing base (3240fcf) to head (cc48a7a).

Files with missing lines Patch % Lines
...a/org/codehaus/groovy/control/CompilationUnit.java 90.6250% 2 Missing and 1 partial ⚠️
src/main/java/groovy/lang/GroovyClassLoader.java 75.0000% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                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     
Files with missing lines Coverage Δ
...rg/codehaus/groovy/classgen/AsmClassGenerator.java 84.7015% <ø> (-0.3384%) ⬇️
src/main/java/groovy/lang/GroovyClassLoader.java 72.3077% <75.0000%> (-0.0161%) ⬇️
...a/org/codehaus/groovy/control/CompilationUnit.java 80.7453% <90.6250%> (+0.1898%) ⬆️

... and 7 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.

@testlens-app

testlens-app Bot commented Jul 24, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: cc48a7a
▶️ Tests: 105866 executed
⚪️ Checks: 31/31 completed


Learn more about TestLens at testlens.app.

@eric-milles eric-milles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't check the nest member attributes that much, but all my tests seem to be holding up fine.

@paulk-asert
paulk-asert merged commit 361a02e into apache:master Jul 24, 2026
32 checks passed
@paulk-asert
paulk-asert deleted the groovy10687postpass branch July 24, 2026 23:02
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.

3 participants