merged from 4.2.x branch: Bug fix: NPE in MoreThanOneLogger

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6074 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Xavier Le Vourch committed 2008-04-28 18:38:09 +00:00
1 parent 0681705690
commit 6f9b9045f0
3 files changed
+17

No files matched your search

+1
View File
@@ -169,6 +169,7 @@ bin and java14/bin scripts:
AvoidDuplicateLiteralRule now has 'skipAnnotations' boolean property
Fixed false positive in UnusedImports: javadoc comments are parsed to check @see and other tags
Fixed parsing bug: constant fields in annotation classes
Bug fix: NPE in MoreThanOneLogger
New rules:
@@ -37,6 +37,17 @@ public class Foo {
class Bar {
Logger log2;
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
ok, fixing NPE bug
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public @interface Foo {
String FOO = "foo";
}
]]></code>
</test-code>
@@ -3,6 +3,7 @@ package net.sourceforge.pmd.lang.java.rule.logging;
import java.util.Stack;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.java.ast.ASTAnnotationTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType;
import net.sourceforge.pmd.lang.java.ast.ASTEnumDeclaration;
@@ -44,6 +45,10 @@ public class MoreThanOneLoggerRule extends AbstractJavaRule {
return init (node, data);
}
public Object visit(ASTAnnotationTypeDeclaration node, Object data) {
return init (node, data);
}
private Object init(JavaNode node, Object data) {
stack.push(count);
count = NumericConstants.ZERO;