pmd: fix NPE in ConstructorCallsOverridableMethodRule

This commit is contained in:
Andreas Dangel
2013-03-15 21:54:02 +01:00
parent 31f6b9af1a
commit c00ca9e44c

View File

@ -941,6 +941,7 @@ public final class ConstructorCallsOverridableMethodRule extends AbstractJavaRul
Node expression = argumentList.jjtGetChild(a);
ASTPrimaryPrefix arg = expression.getFirstDescendantOfType(ASTPrimaryPrefix.class);
String type = "<unknown>";
if (arg != null && arg.jjtGetNumChildren() > 0) {
if (arg.jjtGetChild(0) instanceof ASTLiteral) {
ASTLiteral lit = (ASTLiteral) arg.jjtGetChild(0);
if (lit.isCharLiteral()) {
@ -958,6 +959,7 @@ public final class ConstructorCallsOverridableMethodRule extends AbstractJavaRul
// ASTName n = (ASTName)arg.jjtGetChild(0);
type = "ref";
}
}
argumentTypes.add(type);
}
}