Merge branch 'pr-821'

This commit is contained in:
Andreas Dangel 2018-01-11 17:30:40 +01:00
commit 9bc7074fb9
3 changed files with 17 additions and 3 deletions

View File

@ -55,6 +55,8 @@ at <https://pmd.github.io/latest/>.
* java-bestpractices
* [#783](https://github.com/pmd/pmd/issues/783): \[java] GuardLogStatement regression
* [#800](https://github.com/pmd/pmd/issues/800): \[java] ForLoopCanBeForeach NPE when looping on `this` object
* java-codestyle
* [#817](https://github.com/pmd/pmd/issues/817): \[java] UnnecessaryModifierRule crashes on valid code
* java-design
* [#785](https://github.com/pmd/pmd/issues/785): \[java] NPE in DataClass rule

View File

@ -150,9 +150,11 @@ public class UnnecessaryModifierRule extends AbstractJavaRule {
private boolean isSafeVarargs(final ASTMethodDeclaration node) {
for (final ASTAnnotation annotation : node.jjtGetParent().findChildrenOfType(ASTAnnotation.class)) {
final Node childAnnotation = annotation.jjtGetChild(0);
if (childAnnotation instanceof ASTMarkerAnnotation
&& SafeVarargs.class.isAssignableFrom(((ASTMarkerAnnotation) childAnnotation).getType())) {
return true;
if (childAnnotation instanceof ASTMarkerAnnotation) {
final ASTMarkerAnnotation marker = (ASTMarkerAnnotation) childAnnotation;
if (marker.getType() != null && SafeVarargs.class.isAssignableFrom(marker.getType())) {
return true;
}
}
}

View File

@ -585,6 +585,16 @@ public class Foo {
// do something on fw
}
}
}
]]></code>
</test-code>
<test-code>
<description>#817 [java] UnnecessaryModifierRule crashes on valid code</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
class Foo {
@Bar
final void method() { }
}
]]></code>
</test-code>