forked from phoedos/pmd
merged from trunk: Fixed ClassCastException on generic method in BeanMembersShouldSerialize
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6466 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
Fixed bug 1481051 - false + UnusedNullCheckInEquals (and other false positives too)
|
Fixed bug 1481051 - false + UnusedNullCheckInEquals (and other false positives too)
|
||||||
Fixed bug 1943204 - Ant task: <ruleset> path should be relative to Ant basedir
|
Fixed bug 1943204 - Ant task: <ruleset> path should be relative to Ant basedir
|
||||||
|
Fixed ClassCastException on generic method in BeanMembersShouldSerialize
|
||||||
|
|
||||||
August 31, 2008 - 4.2.3:
|
August 31, 2008 - 4.2.3:
|
||||||
|
|
||||||
|
@@ -155,6 +155,19 @@ public class Foo {
|
|||||||
private String foo;
|
private String foo;
|
||||||
private String bar = Foo.foo;
|
private String bar = Foo.foo;
|
||||||
public void setFoo(Foo foo) {this.foo = foo;}
|
public void setFoo(Foo foo) {this.foo = foo;}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
<test-code>
|
||||||
|
<description><![CDATA[
|
||||||
|
ClassCastException on generic method
|
||||||
|
]]></description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public abstract class List<A> implements Iterable<A> {
|
||||||
|
public static <A> F<List<A>, Boolean> isEmpty() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
@@ -12,6 +12,7 @@ import net.sourceforge.pmd.AbstractRule;
|
|||||||
import net.sourceforge.pmd.PropertyDescriptor;
|
import net.sourceforge.pmd.PropertyDescriptor;
|
||||||
import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
|
import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
|
||||||
import net.sourceforge.pmd.ast.ASTCompilationUnit;
|
import net.sourceforge.pmd.ast.ASTCompilationUnit;
|
||||||
|
import net.sourceforge.pmd.ast.ASTMethodDeclaration;
|
||||||
import net.sourceforge.pmd.ast.ASTMethodDeclarator;
|
import net.sourceforge.pmd.ast.ASTMethodDeclarator;
|
||||||
import net.sourceforge.pmd.ast.ASTPrimitiveType;
|
import net.sourceforge.pmd.ast.ASTPrimitiveType;
|
||||||
import net.sourceforge.pmd.ast.ASTResultType;
|
import net.sourceforge.pmd.ast.ASTResultType;
|
||||||
@@ -97,7 +98,7 @@ public class BeanMembersShouldSerializeRule extends AbstractRule {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (methodName.startsWith("is")) {
|
if (methodName.startsWith("is")) {
|
||||||
ASTResultType ret = (ASTResultType) meth.jjtGetParent().jjtGetChild(0);
|
ASTResultType ret = ((ASTMethodDeclaration) meth.jjtGetParent()).getResultType();
|
||||||
List primitives = ret.findChildrenOfType(ASTPrimitiveType.class);
|
List primitives = ret.findChildrenOfType(ASTPrimitiveType.class);
|
||||||
if (!primitives.isEmpty() && ((ASTPrimitiveType) primitives.get(0)).isBoolean()) {
|
if (!primitives.isEmpty() && ((ASTPrimitiveType) primitives.get(0)).isBoolean()) {
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user