You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] UnnecessaryImport: False positive when Javadoc {@link} references an array type #6651
UnnecessaryImport incorrectly marks an import as unused when it is only referenced in Javadoc {@link} using an array type (e.g. Type[]), while correctly recognizing the same import as used when referenced as Type. This leads to inconsistent false positives.
Code Sample demonstrating the issue:
// BEFORE — no violation reported (correct)packagedemo;
importjava.nio.file.Files;
importjava.nio.file.Path;
importjava.nio.file.attribute.FileAttribute;
/** * See {@link Files#createDirectory(Path, FileAttribute)} for directory creation. */publicclassTest {}
// AFTER — UnnecessaryImport reported on line 5 (false-positive)packagedemo;
importjava.nio.file.Files;
importjava.nio.file.Path;
importjava.nio.file.attribute.FileAttribute;
/** * See {@link Files#createDirectory(Path, FileAttribute[])} for directory creation. */publicclassTest {}
Expected outcome: No UnnecessaryImport violation on the AFTER snippet — an import referenced from a Javadoc {@link} tag should be considered used regardless of whether the reference is written as T or T[].
Actual outcome: PMD reports Unused import 'java.nio.file.attribute.FileAttribute' at line 5 of AFTER, while correctly reporting nothing on BEFORE.
changed the title [-][java] UnnecessaryImport false-positive when Javadoc {@link} references an array type[/-][+][java] UnnecessaryImport: False positive when Javadoc {@link} references an array type[/+]on Aug 20, 2026
Activity
UncleOwen commentedon May 14, 2026
Related to #4325
[java] Fix UnnecessaryImport false positive for array-typed Javadoc {@…
[-][java] UnnecessaryImport false-positive when Javadoc {@link} references an array type[/-][+][java] UnnecessaryImport: False positive when Javadoc {@link} references an array type[/+]