Fix ClassCastException on SignatureDeclareThrowsException

- Java 8 code allows for things such as
   `class UnmodifiableList<T> implements @Readonly List<@Readonly T> {}`
    where not all token in the ASTImplementsList are ASTClassOrInterfaceType
This commit is contained in:
Juan Martín Sotuyo Dodero
2016-10-12 18:06:52 -03:00
committed by Andreas Dangel
parent 020170bd76
commit f8d1162886

View File

@@ -50,7 +50,13 @@ public class SignatureDeclareThrowsException extends AbstractJavaRule {
ASTImplementsList impl = node.getFirstChildOfType(ASTImplementsList.class);
if (impl != null && impl.jjtGetParent().equals(node)) {
for (int ix = 0; ix < impl.jjtGetNumChildren(); ix++) {
ASTClassOrInterfaceType type = (ASTClassOrInterfaceType) impl.jjtGetChild(ix);
Node child = impl.jjtGetChild(ix);
if (child.getClass() != ASTClassOrInterfaceType.class) {
continue;
}
ASTClassOrInterfaceType type = (ASTClassOrInterfaceType) child;
if (isJUnitTest(type)) {
junitImported = true;
return super.visit(node, data);