In Java 8, annotations may appear as first child
- For instance `Object o = new @Interned MyObject();` would fail with a ClassCastException - The current code deals with it gracefully
This commit is contained in:
Juan Martín Sotuyo Dodero
committed by
Andreas Dangel
parent
5d11e77208
commit
1e5c1c05ca
@ -3,6 +3,7 @@
|
||||
*/
|
||||
package net.sourceforge.pmd.lang.java.rule.basic;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTAllocationExpression;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTArrayDimsAndInits;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTBooleanLiteral;
|
||||
@ -63,7 +64,9 @@ public class BooleanInstantiationRule extends AbstractJavaRule {
|
||||
if (node.hasDescendantOfType(ASTArrayDimsAndInits.class)) {
|
||||
return super.visit(node, data);
|
||||
}
|
||||
if (TypeHelper.isA((ASTClassOrInterfaceType) node.jjtGetChild(0), Boolean.class)) {
|
||||
|
||||
Node n1 = node.getFirstChildOfType(ASTClassOrInterfaceType.class);
|
||||
if (TypeHelper.isA((ASTClassOrInterfaceType) n1, Boolean.class)) {
|
||||
super.addViolation(data, node);
|
||||
return data;
|
||||
}
|
||||
|
Reference in New Issue
Block a user