facebook / facebook/infer

[java] A false negative about the rule NULL_DEREFERENCE

Open
#1,792 0 comments 0 reactions 0 assignees View on GitHub
false-negative java
Dominant language
OCaml
Stars
15.7k
Forks
2.1k
Avg merge
19h 36m
Merged PRs (30d)
13

Description

**Version**. `Infer version v1.1.0`
**OS**. `Ubuntu 22.04.3 LTS`
**Command**. `infer run -- mvn clean compile`

I found a false negative about the rule [NULL_DEREFERENCE](https://fbinfer.com/docs/all-issue-types#null_dereference).

In the example below, Infer report no warnings, but there is a NULL_DEREFERENCE bug at line 6.

```java
import com.android.annotations.Nullable;
class A {
@Nullable
A obj;
public void fun() {
synchronized (obj) { // report no warnings
synchronized (this) {}
}
}
}
```

However, if I use `androidx.annotation.Nullable` instead of `com.android.annotations.Nullable`, Infer can report a warning at line 6. Hence, I think it is a false negative.

```bash
error: Null Dereference object `obj` last accessed on line 6 could be null and is dereferenced at line 6.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.