Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[java] infer ignores assert behaviour #68

Closed
Keruspe opened this issue Jun 16, 2015 · 2 comments
Closed

[java] infer ignores assert behaviour #68

Keruspe opened this issue Jun 16, 2015 · 2 comments

Comments

@Keruspe
Copy link

Keruspe commented Jun 16, 2015

infer doesn't seem to know the assert keyword or to handle it correctly.
Simple reproducer:

keruspe@Lou /tmp/infer % cat test.java                                            
public class test {
    int test() {
        String s = null;
        return s.length();
    }
}
keruspe@Lou /tmp/infer % infer -- javac test.java                                 
Starting analysis (Infer version git-17f0b5cbe2a1d4dd5831c79ce43bdb6c0e5da230)
Analysis done

1 file analyzed


/tmp/infer/test.java:4: error: NULL_DEREFERENCE
   object s last assigned on line 3 could be null and is dereferenced at line 4

keruspe@Lou /tmp/infer % vim test.java                                            
keruspe@Lou /tmp/infer % cat test.java                                            
public class test {
    int test() {
        String s = null;
        assert s != null;
        return s.length();
    }
}
keruspe@Lou /tmp/infer % infer -- javac test.java                                 
Starting analysis (Infer version git-17f0b5cbe2a1d4dd5831c79ce43bdb6c0e5da230)
Analysis done

1 file analyzed


/tmp/infer/test.java:5: error: NULL_DEREFERENCE
   object s last assigned on line 3 could be null and is dereferenced at line 5

I expect this last infer run not to tell be s can be null as the assert just above tells otherwise

@jvillard
Copy link
Contributor

Hi @Keruspe, thanks for your report. It looks like this can be solved by adding a model for AssertionError. I'll look into it.

@jvillard jvillard self-assigned this Jun 16, 2015
@irpap irpap closed this as completed Jun 18, 2015
@irpap
Copy link
Contributor

irpap commented Jun 18, 2015

This should be fixed in the last release.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants