Merge branch 'pr-1267'

This commit is contained in:
Andreas Dangel
2018-08-06 09:09:45 +02:00
2 changed files with 24 additions and 17 deletions

View File

@ -30,6 +30,8 @@ This is a minor release.
* core
* [#1191](https://github.com/pmd/pmd/issues/1191): \[core] Test Framework: Sort violations by line/column
* java-bestpractices
* [#1267](https://github.com/pmd/pmd/pull/1267): \[java] MissingOverrideRule: Avoid NoClassDefFoundError with incomplete classpath
* java-codestyle
* [#1255](https://github.com/pmd/pmd/issues/1255): \[java] UnnecessaryFullyQualifiedName false positive: static method on shadowed implicitly imported class
* java-errorprone

View File

@ -109,25 +109,30 @@ public class MissingOverrideRule extends AbstractJavaRule {
return null;
}
Set<Method> overridden = overriddenMethods(exploredType);
Map<String, Map<Integer, List<Method>>> result = new HashMap<>();
for (Method m : exploredType.getDeclaredMethods()) {
if (!result.containsKey(m.getName())) {
result.put(m.getName(), new HashMap<Integer, List<Method>>());
try {
Set<Method> overridden = overriddenMethods(exploredType);
Map<String, Map<Integer, List<Method>>> result = new HashMap<>();
for (Method m : exploredType.getDeclaredMethods()) {
if (!result.containsKey(m.getName())) {
result.put(m.getName(), new HashMap<Integer, List<Method>>());
}
Map<Integer, List<Method>> pCountToOverloads = result.get(m.getName());
int paramCount = m.getParameterTypes().length;
if (!pCountToOverloads.containsKey(paramCount)) {
pCountToOverloads.put(paramCount, new ArrayList<Method>());
}
pCountToOverloads.get(paramCount).add(m);
}
Map<Integer, List<Method>> pCountToOverloads = result.get(m.getName());
int paramCount = m.getParameterTypes().length;
if (!pCountToOverloads.containsKey(paramCount)) {
pCountToOverloads.put(paramCount, new ArrayList<Method>());
}
pCountToOverloads.get(paramCount).add(m);
return new MethodLookup(result, overridden);
} catch (final LinkageError e) {
// we may have an incomplete auxclasspath
return null;
}
return new MethodLookup(result, overridden);
}