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

Nullness Checker: unsoundness with unboxing UnknownInitialization types #297

Closed
wmdietl opened this issue Jul 15, 2022 · 0 comments · Fixed by #444
Closed

Nullness Checker: unsoundness with unboxing UnknownInitialization types #297

wmdietl opened this issue Jul 15, 2022 · 0 comments · Fixed by #444

Comments

@wmdietl
Copy link
Member

wmdietl commented Jul 15, 2022

This example:

import org.checkerframework.checker.initialization.qual.UnknownInitialization;

class Demo {
  @UnknownInitialization Integer n;
  
  Demo() {
    int y = n;
  }
  
  public static void main(String[] args) {
      new Demo();
  }
}

passes the Nullness Checker without an error or warning.
Executing it produces an NPE.

When the field n is not annotated, making it UnderInitialization in the constructor, the correct error is raised.

Neither version warns about the field not being initialized by the constructor, which is maybe OK when a different error is raised.

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

Successfully merging a pull request may close this issue.

1 participant