forked from phoedos/pmd
[java] Avoid errors upon resolving invalid classes
- Resolves #328 - Take the chance to simplify some error handling (`NoClassDefFoundError` extends `LinkageError`)
This commit is contained in:
@ -532,6 +532,9 @@ public class TypeSet {
|
||||
return resolver.resolve(name);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
// ignored, maybe another resolver will find the class
|
||||
} catch (LinkageError le) {
|
||||
// we found the class, but there is a problem with it (see https://github.com/pmd/pmd/issues/328)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1298,8 +1298,6 @@ public class ClassTypeResolver extends JavaParserVisitorAdapter {
|
||||
myType = pmdClassLoader.loadClass(qualifiedName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
myType = processOnDemand(qualifiedName);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
myType = processOnDemand(qualifiedName);
|
||||
} catch (LinkageError e) {
|
||||
myType = processOnDemand(qualifiedName);
|
||||
}
|
||||
@ -1430,7 +1428,7 @@ public class ClassTypeResolver extends JavaParserVisitorAdapter {
|
||||
String strName = anImportDeclaration.getImportedName();
|
||||
String fieldName = strName.substring(strName.lastIndexOf('.') + 1);
|
||||
|
||||
Class staticClassWithField = loadClass(strPackage);
|
||||
Class<?> staticClassWithField = loadClass(strPackage);
|
||||
if (staticClassWithField != null) {
|
||||
JavaTypeDefinition typeDef = getFieldType(JavaTypeDefinition.forClass(staticClassWithField),
|
||||
fieldName, currentAcu.getType());
|
||||
|
Reference in New Issue
Block a user