GROOVY-12157: Covariant bridge methods are emitted in hash order, not…#2702
Merged
Conversation
… the order they are found
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2702 +/- ##
==================================================
+ Coverage 69.1077% 69.1155% +0.0077%
- Complexity 34235 34239 +4
==================================================
Files 1537 1537
Lines 129356 129356
Branches 23503 23503
==================================================
+ Hits 89395 89405 +10
+ Misses 31941 31933 -8
+ Partials 8020 8018 -2
🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: e0fe323 Learn more about TestLens at testlens.app. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes nondeterministic bytecode output by ensuring covariant bridge methods added by Verifier are emitted in discovery order (rather than HashMap iteration order), improving reproducibility of generated .class files for identical sources.
Changes:
- Switches the internal bridge-method collection maps in
Verifier.addCovariantMethodsfromHashMaptoLinkedHashMapto preserve insertion order during iteration. - Adds a regression test that compiles a sample class with multiple covariant overrides and asserts the resulting bridge method order in the class file.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/test/groovy/org/codehaus/groovy/classgen/CovariantBridgeMethodOrderTest.groovy | New regression test asserting deterministic, declaration-ordered bridge method emission by inspecting class bytes via ASM. |
| src/main/java/org/codehaus/groovy/classgen/Verifier.java | Uses insertion-ordered maps for collecting/iterating interface methods and bridge methods so emission order is stable and reproducible. |
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.
… the order they are found