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] UseArrayListInsteadOfVector ignores Vector when other classes are imported #4148
Description:
Hi, I found a false negative about the rule UseArrayListInsteadOfVector, please read the first code example below. PMD should have reported a warning in line 5, but it does not. However, in the second code example, PMD can report the warning as expected. Hence, I think this is a false negative. Thank you!
Code Sample demonstrating the issue:
First code example
importorg.Annotation;
@AnnotationpublicclassC {
voidx() {
Vectorv = newVector(); // should report a warning in this line, but no warnings
}
}
Second code example
publicclassC {
voidx() {
Vectorv = newVector(); // Can detect the warning
}
}
Expected outcome:
PMD should report a violation at line 5, but doesn't. This is a false-negative.
changed the title [-][java] UseArrayListInsteadOfVector should detect the method with annotation[/-][+][java] UseArrayListInsteadOfVector ignores Vector when other classes are imported[/+]on Oct 14, 2022
Thanks for the report.
It is not the Annotation, that trips the rule, but the other import, e.g. here we also don't detect Vector:
importsome.OtherClass;
publicclassC {
voidx() {
java.util.Vectorv = newjava.util.Vector(); // Can detect the warning
}
}
Note: your example doesn't really compile, because you didn't import "java.util.Vector". As soon as you add import java.util.Vector; additionally, it works.
Activity
[-][java] UseArrayListInsteadOfVector should detect the method with annotation[/-][+][java] UseArrayListInsteadOfVector ignores Vector when other classes are imported[/+]adangel commentedon Oct 14, 2022
Thanks for the report.
It is not the Annotation, that trips the rule, but the other import, e.g. here we also don't detect
Vector:Note: your example doesn't really compile, because you didn't import "java.util.Vector". As soon as you add
import java.util.Vector;additionally, it works.[java] Use type resolution for UseArrayListInsteadOfVector