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

False positive with Objects.toString #4889

Closed
cushon opened this issue Aug 14, 2021 · 1 comment · Fixed by #4897
Closed

False positive with Objects.toString #4889

cushon opened this issue Aug 14, 2021 · 1 comment · Fixed by #4897
Assignees

Comments

@cushon
Copy link
Contributor

cushon commented Aug 14, 2021

After typetools/jdk@8b50438, the nullness checker reports the following false positive. Should the first parameter of Objects.toString be annotated @Nullable instead of @PolyNull?

import java.util.Objects;
import org.checkerframework.checker.nullness.qual.Nullable;

class T {
  void f(@Nullable String s) {
    Objects.toString(s, "").toString();
  }
}
$ ./checker/bin/javac -processor Nullness T.java
...
T.java:6: error: [dereference.of.nullable] dereference of possibly-null reference Objects.toString(s, "")
    Objects.toString(s, "").toString();
mernst added a commit to mernst/checker-framework that referenced this issue Aug 19, 2021
@mernst
Copy link
Member

mernst commented Aug 19, 2021

Liam, you are right; I should have added @PolyNull only where there was no annotation before.
Thank you for the bug report!

mernst added a commit that referenced this issue Aug 20, 2021
wmdietl pushed a commit to eisop/checker-framework that referenced this issue Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants