Repository navigation
[java] Fix #7009: ReplaceJavaUtilDate/Calendar miss pattern variables and record components - #7010
Merged
Merged
Conversation
Both rules matched only LocalVariableDeclaration, FormalParameter, FieldDeclaration and ConstructorCall, so a variable introduced by a pattern was never reported. Add TypePattern to both XPath expressions, which covers instanceof patterns, switch case labels and the component patterns of a record deconstruction.
Contributor
|
Compared to main: (comment created at 2026-08-30 17:24:40+00:00 for 82afe35) |
UncleOwen
requested changes
Aug 30, 2026
Member
Feel free to add those as well. |
Follow-up to the review on pmd#7010. Add RecordComponent to both XPath expressions, so a record component declared as java.util.Date or java.util.Calendar is reported. Varargs components parse as an array type and stay unreported, which matches how Date[] parameters behave today. Replace the java.sql.Timestamp test case with a fully qualified java.util.Date one, so nothing added here depends on the java.sql behaviour discussed in pmd#6025. Let the record deconstruction test declare record Box(Object value), so it keeps covering only the nested type pattern now that the record component itself is reported too.
…ern-variable # Conflicts: # docs/pages/release_notes.md
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.
Describe the PR
Both rules match only
LocalVariableDeclaration,FormalParameter,FieldDeclarationandConstructorCall, so neither a pattern variable nor a record component is reported.TypePatterncoversinstanceofpatterns,switchcase labels and the components of a record deconstruction pattern.RecordComponentcovers record component declarations.With only the new test cases applied they report 0 problems and fail; with the XPath change all 21 pass in the two rule tests.
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)