GROOVY-12146: order reflection calls to ensure Annotation members are ordered#2687
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## GROOVY_5_0_X #2687 +/- ##
======================================================
+ Coverage 67.2477% 67.2962% +0.0484%
+ Complexity 29571 29569 -2
======================================================
Files 1382 1382
Lines 116972 117185 +213
Branches 20539 20676 +137
======================================================
+ Hits 78661 78861 +200
- Misses 31788 31790 +2
- Partials 6523 6534 +11
🚀 New features to boost your workflow:
|
Contributor
|
LGTM |
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.
Fixes https://issues.apache.org/jira/browse/GROOVY-12146 by canonicalizing at the source of the nondeterminism instead of at emission (the reverted 4.x approach also reordered source-compiled annotations, which stay in deterministic source order and don't need touching):
// Java8#configureAnnotation
declaredMethods = type.getDeclaredMethods();
Arrays.sort(declaredMethods, Comparator.comparing(Method::getName));
Annotation member methods cannot overload, so name gives a total order. Verified locally against GROOVY_5_0_X: the woven class emits a stable sorted order independent of the JVM, source-compiled annotations are unchanged, and TypeAnnotationsTest plus the trait transform suites pass.