The rule does not take into account, the necessity to distinguish between the imported class and a user defined class of the same name.
import java.util.*;
final class Test {
private Test() { }
private static class Locale {
public final java.util.Locale locale; // Here we need to fully qualify
public Locale(final String tag) {
this.locale = java.util.Locale.forLanguageTag(tag);
}
}
// ...
// Lots of uses of classes imported by java.util.*
// ...
public static void main(String[] args) {
final Locale l = new Locale("fr-CA");
System.out.println(l.toString());
}
}
This one is another case of conflict resolution, such as https://sourceforge.net/p/pmd/bugs/1546/
However, the fix for that issue doesn't cover this one. I'll try to get it fixed.
Last edit: Juan Sotuyo 2016-12-10
PR submitted: https://github.com/pmd/pmd/pull/159
This bug will be fixed with PMD 5.4.4, 5.5.3 and later.