Fixed bug 2645268 - ClassCastException in UselessOperationOnImmutable.getDeclaration
Problem was due to incorrect assumption about AST structure, when Annotations are present on a local declaration. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6880 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
1 parent
1254933e74
commit
1b2aabc93b
3 files changed
+17
-2
No files matched your search
@@ -428,6 +428,7 @@ Fixed bug 1609038 - Xslt report generators break if path contains "java"
|
||||
Fixed bug 2142986 - UselessOverridingMethod doesn't consider annotations
|
||||
Fixed bug 2027626 - False + : AvoidFinalLocalVariable
|
||||
Fixed bug 2606609 - False "UnusedImports" positive in package-info.java
|
||||
Fixed bug 2645268 - ClassCastException in UselessOperationOnImmutable.getDeclaration
|
||||
|
||||
ruleset.dtd and ruleset_xml_schema.xsd added to jar file in rulesets directory
|
||||
bin and java14/bin scripts:
|
||||
|
||||
+15
-1
@@ -161,5 +161,19 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
2645268, ClassCastException using Annotation on Local Field
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public void foo() {
|
||||
@NotNull
|
||||
BigDecimal bd = new BigDecimal(5);
|
||||
bd.divideToIntegralValue(new BigDecimal(5));
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
+1
-1
@@ -86,7 +86,7 @@ public class UselessOperationOnImmutableRule extends AbstractJavaRule {
|
||||
private ASTVariableDeclaratorId getDeclaration(ASTLocalVariableDeclaration node) {
|
||||
ASTType type = node.getTypeNode();
|
||||
if (MAP_CLASSES.keySet().contains(type.getTypeImage())) {
|
||||
return (ASTVariableDeclaratorId) node.jjtGetChild(1).jjtGetChild(0);
|
||||
return node.getFirstDescendantOfType(ASTVariableDeclaratorId.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user