diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index 8544ed8795..8ad872e8f4 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -3,6 +3,7 @@ Fixed bug 2590258 - NPE with nicerhtml output Fixed bug 2317099 - False + in SimplifyCondition Fixed bug 2606609 - False "UnusedImports" positive in package-info.java +Fixed bug 2645268 - ClassCastException in UselessOperationOnImmutable.getDeclaration New rule: StrictExceptions : AvoidCatchingGenericException diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/UselessOperationOnImmutable.xml b/pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/UselessOperationOnImmutable.xml index 2c94925329..357527c78b 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/UselessOperationOnImmutable.xml +++ b/pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/UselessOperationOnImmutable.xml @@ -180,6 +180,21 @@ public BigDecimal myMethod(Object pObj) //... return cout; +} + ]]> + + + + 1 + diff --git a/pmd/src/net/sourceforge/pmd/rules/UselessOperationOnImmutable.java b/pmd/src/net/sourceforge/pmd/rules/UselessOperationOnImmutable.java index f8fb8c847e..715556049b 100644 --- a/pmd/src/net/sourceforge/pmd/rules/UselessOperationOnImmutable.java +++ b/pmd/src/net/sourceforge/pmd/rules/UselessOperationOnImmutable.java @@ -86,7 +86,7 @@ public class UselessOperationOnImmutable extends AbstractJavaRule { private ASTVariableDeclaratorId getDeclaration(ASTLocalVariableDeclaration node) { ASTType type = node.getTypeNode(); if (mapClasses.keySet().contains(type.getTypeImage())) { - return (ASTVariableDeclaratorId) node.jjtGetChild(1).jjtGetChild(0); + return node.findChildrenOfType(ASTVariableDeclaratorId.class).get(0); } return null; }