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 for on-demand imports with incomplete aux-classpath #7215
When a class is referenced through an on-demand import (import p.*;), PMD reports the import as unused even though one of its members is in fact used in the file. Replacing the wildcard with the equivalent single-type import (import p.C;) makes the warning disappear, although in both cases C is resolved through that import statement.
changed the title [-][java] UnnecessaryImport: false positive on on-demand (wildcard) imports whose member is actually used[/-][+][java] UnnecessaryImport: False positive on on-demand (wildcard) imports whose member is actually used[/+]on Nov 6, 2026
changed the title [-][java] UnnecessaryImport: False positive on on-demand (wildcard) imports whose member is actually used[/-][+][java] UnnecessaryImport: False positive on on-demand (wildcard) imports whose member is actually used (incomplete aux-classpath)[/+]on Nov 13, 2026
changed the title [-][java] UnnecessaryImport: False positive on on-demand (wildcard) imports whose member is actually used (incomplete aux-classpath)[/-][+][java] UnnecessaryImport: False positive for on-demand imports with incomplete aux-classpath[/+]on Nov 13, 2026
Activity
Eymenonar commentedon Oct 21, 2026
I can take this one. I’ll add a regression test and fix the unresolved qualified-type handling for on-demand imports.
[-][java] UnnecessaryImport: false positive on on-demand (wildcard) imports whose member is actually used[/-][+][java] UnnecessaryImport: False positive on on-demand (wildcard) imports whose member is actually used[/+]adangel commentedon Nov 13, 2026
Assuming this is a missing aux-classpath problem. Anyone tried to call PMD with the compiled project?
adangel commentedon Nov 13, 2026
Ok, answering myself: This has been confirmed: #7217 (comment) and #7217 (comment)
[-][java] UnnecessaryImport: False positive on on-demand (wildcard) imports whose member is actually used[/-][+][java] UnnecessaryImport: False positive on on-demand (wildcard) imports whose member is actually used (incomplete aux-classpath)[/+][-][java] UnnecessaryImport: False positive on on-demand (wildcard) imports whose member is actually used (incomplete aux-classpath)[/-][+][java] UnnecessaryImport: False positive for on-demand imports with incomplete aux-classpath[/+]adangel commentedon Nov 13, 2026
Just to be clear, if all the types can be resolved, there is no problem:
[java] UnnecessaryImport: Keep static on-demand imports for unresolve…
[java] Fix pmd#7215: Handle qualified types from unresolved on-demand…