diff --git a/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/coupling/LooseCouplingRule.java b/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/coupling/LooseCouplingRule.java index 573e6ae90b..4bf0fb0b50 100644 --- a/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/coupling/LooseCouplingRule.java +++ b/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/coupling/LooseCouplingRule.java @@ -39,7 +39,7 @@ public class LooseCouplingRule extends AbstractJavaRule { private boolean methodHasOverride(Node node) { ASTClassOrInterfaceBodyDeclaration method = node.getFirstParentOfType(ASTClassOrInterfaceBodyDeclaration.class); - if (method.jjtGetNumChildren() > 0 && method.jjtGetChild(0) instanceof ASTAnnotation) { + if (method != null && method.jjtGetNumChildren() > 0 && method.jjtGetChild(0) instanceof ASTAnnotation) { ASTMarkerAnnotation marker = method.getFirstDescendantOfType(ASTMarkerAnnotation.class); if (marker != null && marker.getFirstChildOfType(ASTName.class) != null) { ASTName name = marker.getFirstChildOfType(ASTName.class); diff --git a/pmd/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/rules/LooseCoupling.java b/pmd/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/rules/LooseCoupling.java index ac71341846..30a9cd2639 100644 --- a/pmd/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/rules/LooseCoupling.java +++ b/pmd/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/rules/LooseCoupling.java @@ -37,11 +37,10 @@ public class LooseCoupling extends AbstractJavaRule { private boolean methodHasOverride(Node node) { ASTClassOrInterfaceBodyDeclaration method = node.getFirstParentOfType(ASTClassOrInterfaceBodyDeclaration.class); - if (method.jjtGetNumChildren() > 0 && method.jjtGetChild(0) instanceof ASTAnnotation) { + if (method != null && method.jjtGetNumChildren() > 0 && method.jjtGetChild(0) instanceof ASTAnnotation) { ASTMarkerAnnotation marker = method.getFirstDescendantOfType(ASTMarkerAnnotation.class); if (marker != null && marker.getFirstChildOfType(ASTName.class) != null) { ASTName name = marker.getFirstChildOfType(ASTName.class); - System.out.println(name.getType()); if (name.getType() == Override.class) { return true; }