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
@@ -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;
}
}