apache / apache/netbeans

NPECheck (the “Null Pointer Dereference” hint) should support `@Target(TYPE_USE)` annotations

Open
#4,125 3 comments 0 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 13

### What happened

Using a `@NonNull` or `@Nullable` annotation that has \@[Target][java.lang.annotation.Target]\([TYPE_USE][java.lang.annotation.ElementType#TYPE_USE]\) causes the “Null Pointer Dereference” hint to not work.

### How to reproduce

Use a `@NotNull` or `@Nullable` annotation that has `@Target(TYPE_USE)`, such as the ones provided by [JSpecify](https://jspecify.dev/).

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

No

### Operating System

Windows 10

### JDK

OpenJDK Runtime Environment [Temurin](https://adoptium.net/)-18.0.1+10 (build 18.0.1+10)

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

Nullity annotations that make use of **Java 8**’s [ElementType][java.lang.annotation.ElementType].[TYPE_USE][java.lang.annotation.ElementType#TYPE_USE] are becoming more and more common as time goes on[^1].

[^1]: They’re already in use in [Guava](https://github.com/google/guava)

[java.lang.annotation.Target]: https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/lang/annotation/Target.html
[java.lang.annotation.ElementType]: https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/lang/annotation/ElementType.html
[java.lang.annotation.ElementType#TYPE_USE]: https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/lang/annotation/ElementType.html#TYPE_USE

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

No

### Code of Conduct

Yes

Contributor guide

Open the contributing guide

Research direction

Start by locating the NPECheck hint and its handling of nullity annotations. Reproduce the issue with a @NotNull or @Nullable annotation targeted at TYPE_USE, such as a JSpecify annotation, then verify that the Null Pointer Dereference hint works for that case.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.