ciera / crystalsaf

Automatically exported from code.google.com/p/crystalsaf
3 stars 2 forks source link

Crystal ignores instanceof checks during NPE analysis #30

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create java code that calls static methods.
2. Run Crystal

Sample code:
private class Main {
    public void myMethod(Object arg) {
        if (arg instanceof Integer) {
            System.out.println(((Integer) arg).intValue);
        }
    }
}

What is the expected output? What do you see instead?
I can see Crystal reports via various analysis that expression "(Integer) arg" 
may be null. However this is wrong since the expression "arg instanceof 
Integer" in the if condition already does a null check and apparently analysis 
ignore this fact.

What version of the Crystal are you using?
3.5.2

Original issue reported on code.google.com by jn.rouvignac@gmail.com on 10 Jul 2014 at 8:24

GoogleCodeExporter commented 9 years ago
Just a note: the sample null analyzers that are not branch sensitive should 
rightly ignore this. The branch sensitive one should probably address this case.

Original comment by ciera.christopher on 9 Nov 2014 at 9:31