Skip to content

[java] Fix #4576: UseShortArrayInitializer with arrays of parametrized types (generic array creation) - #6310

Closed
mrclmh wants to merge 2 commits into
pmd:mainfrom
mrclmh:issue-4576
Closed

mrclmh wants to merge 2 commits into
pmd:mainfrom
mrclmh:issue-4576

Conversation

@mrclmh

@mrclmh mrclmh commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

Describe the PR

Do not report arrays with parametrized types because the short version is a 'generic array creation' compiler error.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@pmd-actions-helper

pmd-actions-helper Bot commented Dec 4, 2025 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 1 violations, 15 errors and 8 configuration errors.

Regression Tester Report

(comment created at 2026-01-07 17:49:17+00:00 for 7839618)

@oowekyala

Copy link
Copy Markdown
Member

Some of the removed violations are legit, however cases like this should still be reported:

https://github.com/spring-projects/spring-framework/blob/v5.3.13/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java#L60

Only if some type argument is not an unbounded wildcard should we skip reporting.

@mrclmh
mrclmh marked this pull request as draft January 6, 2026 19:23
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.

[java] UseShortArrayInitializer: False positive with arrays of parametrized types (generic array creation)

2 participants