don't let null checks affect 'unchecked cast' analysis

This commit is contained in:
peter
2012-12-27 16:03:48 +01:00
parent dc22cda945
commit 4a3f20d72f
4 changed files with 18 additions and 3 deletions
@@ -36,7 +36,7 @@ class Test {
System.out.println(r);
}
catch (Exception e) {
if (e instanceof ResourcefulException1) {
if (<warning descr="Condition 'e instanceof ResourcefulException1' is always 'false'">e instanceof ResourcefulException1</warning>) {
System.out.println("1");
}
else if (e instanceof ResourcefulException2) {
@@ -0,0 +1,15 @@
public class DataFlowBug {
public int add2(Object left, Object right) {
if (left != null && !(left instanceof String)) {
return ((<warning descr="Casting 'left' to 'String' may produce 'java.lang.ClassCastException'">String</warning>) left).length();
}
if (!(right instanceof String)) {
return ((<warning descr="Casting 'right' to 'String' may produce 'java.lang.ClassCastException'">String</warning>) right).length();
}
return 2;
}
}