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

dereference.of.nullable on a local variable after call in nested try-finally #3015

Open
cpovirk opened this issue Dec 23, 2019 · 1 comment

Comments

@cpovirk
Copy link
Contributor

cpovirk commented Dec 23, 2019

Minimized from the real code:

$ cat Monitor.java
class Monitor {
  void acquire() {
    String s = "";

    try {
      return;
    } finally {
      try {
        signal();
      } finally {
        s.toString();
      }
    }
  }

  void signal() {}
}

$ checker/bin/javac -processor org.checkerframework.checker.nullness.NullnessChecker Monitor.java
Monitor.java:11: error: [dereference.of.nullable] dereference of possibly-null reference s
        s.toString();
        ^
1 error

I don't think there's a way for s to be null there.

Source file and -version -verbose -AprintAllQualifiers output attached.

@mernst
Copy link
Member

mernst commented Dec 24, 2019

Thanks for the report, Chris. I can't seem to minimize this any further (which I presume is because you did the same thing.)

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

2 participants