apache / apache/netbeans

Wrong warning - Unboxing possibly null value

Open
#6,392 0 comments 3 reactions 0 assignees View on GitHub
hints Java kind:bug
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 18

### What happened

Editor is showing a warning about unboxing possibly null value when the check for possibly null value is added.

### How to reproduce

```java
public class NewClass {

public void test(TestClass arg) {
long testVal1 = arg.getValue(); //this line should/could show a warning, but it doesn't
long testVal2 = arg.getValue() != null?arg.getValue():0; //this line shouldn't show a warning, but it does
}


public class TestClass {
private final Long value = null;

public Long getValue() {
return value;
}
}
}
```

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Windows 10 Pro (2H22) running on amd64; Cp1250; en_US (nb)

### JDK

Java 11; OpenJDK 64-Bit Server VM 11+28

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

_No response_

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the warning in Apache NetBeans 18 with the Java sample from the issue. Trace the Java editor's nullability analysis for the conditional check and the unboxing assignment. Done means the direct unboxing is warned about and the guarded conditional expression is not.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.