Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

NPE not detected #500

Open
trulex opened this issue Nov 10, 2016 · 1 comment
Open

NPE not detected #500

trulex opened this issue Nov 10, 2016 · 1 comment

Comments

@trulex
Copy link

trulex commented Nov 10, 2016

Analyze the following class:

public class Hello {

    private static Integer i;

  static Integer getInteger() {
      return i;
  }


  public static void main(String[] args) {
    Integer i = getInteger();
    i = i + 2;
  }

}

NPE is not detected. If you execute the program it will throw java.lang.NullPointerException.

@sblackshear
Copy link
Contributor

This is a known issue because Infer doesn't model invocation of class initializers (where the implicit assignment to null happens). Modeling class initializers correctly is tricky and can cause noise, so we do not bother with it.

For fully exhaustive checking of NPE related issues that will detect this case, I recommend you give Eradicate (infer -a eradicate) a try.

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

No branches or pull requests

3 participants