GROOVY-12159: Synthetic class-literal fields and accessors are emitte…#2704
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2704 +/- ##
==================================================
- Coverage 69.1077% 69.1062% -0.0015%
+ Complexity 34235 34233 -2
==================================================
Files 1537 1537
Lines 129356 129356
Branches 23503 23503
==================================================
- Hits 89395 89393 -2
- Misses 31941 31942 +1
- Partials 8020 8021 +1
🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes deterministic bytecode output for synthetic class-literal helper members by ensuring class-literal helper fields/accessors are emitted in encounter order (rather than HashMap iteration order), and adds a regression test to lock in the behavior.
Changes:
- Switch
AsmClassGenerator.referencedClassesto an insertion-ordered map to preserve encounter order when generating synthetic class-literal fields/accessors. - Add a new ASM-based regression test that compiles two compilation units and asserts the
$class$...fields and$get$$class$...accessors appear in the expected order in the resulting class file.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java | Preserve encounter order for synthetic class-literal helpers by iterating an insertion-ordered map. |
| src/test/groovy/org/codehaus/groovy/classgen/SyntheticClassLiteralFieldOrderTest.groovy | New regression test asserting synthetic class-literal fields/accessors are emitted in encounter order. |
…d in hash order, not the order the literals were encountered
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.
…d in hash order, not the order the literals were encountered