diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index c0c11af3f0..df52ffdbb7 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -2,6 +2,7 @@ Fixed bug 1481051 - false + UnusedNullCheckInEquals (and other false positives too) Fixed bug 1943204 - Ant task: path should be relative to Ant basedir +Fixed ClassCastException on generic method in BeanMembersShouldSerialize August 31, 2008 - 4.2.3: diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/javabeans/xml/BeanMembersShouldSerialize.xml b/pmd/regress/test/net/sourceforge/pmd/rules/javabeans/xml/BeanMembersShouldSerialize.xml index 3d7ffb98fd..b9fccaa2a0 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/javabeans/xml/BeanMembersShouldSerialize.xml +++ b/pmd/regress/test/net/sourceforge/pmd/rules/javabeans/xml/BeanMembersShouldSerialize.xml @@ -158,4 +158,17 @@ public class Foo { } ]]> - \ No newline at end of file + + + 0 + implements Iterable { + public static F, Boolean> isEmpty() { + return null; + } +} + ]]> + + diff --git a/pmd/src/net/sourceforge/pmd/rules/BeanMembersShouldSerializeRule.java b/pmd/src/net/sourceforge/pmd/rules/BeanMembersShouldSerializeRule.java index 8e20cdf99e..811132e25c 100644 --- a/pmd/src/net/sourceforge/pmd/rules/BeanMembersShouldSerializeRule.java +++ b/pmd/src/net/sourceforge/pmd/rules/BeanMembersShouldSerializeRule.java @@ -12,6 +12,7 @@ import net.sourceforge.pmd.AbstractRule; import net.sourceforge.pmd.PropertyDescriptor; import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration; import net.sourceforge.pmd.ast.ASTCompilationUnit; +import net.sourceforge.pmd.ast.ASTMethodDeclaration; import net.sourceforge.pmd.ast.ASTMethodDeclarator; import net.sourceforge.pmd.ast.ASTPrimitiveType; import net.sourceforge.pmd.ast.ASTResultType; @@ -97,7 +98,7 @@ public class BeanMembersShouldSerializeRule extends AbstractRule { return true; } if (methodName.startsWith("is")) { - ASTResultType ret = (ASTResultType) meth.jjtGetParent().jjtGetChild(0); + ASTResultType ret = ((ASTMethodDeclaration) meth.jjtGetParent()).getResultType(); List primitives = ret.findChildrenOfType(ASTPrimitiveType.class); if (!primitives.isEmpty() && ((ASTPrimitiveType) primitives.get(0)).isBoolean()) { return true;