netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

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

Open ExE-Boss opened this issue 3 years ago • 2 comments

Apache NetBeans version

Apache NetBeans 13

What happened

Using a @NonNull or @Nullable annotation that has @Target(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.

Did this work correctly in an earlier version?

No

Operating System

Windows 10

JDK

OpenJDK Runtime Environment Temurin-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.TYPE_USE are becoming more and more common as time goes on[^1].

[^1]: They’re already in use in Guava

Are you willing to submit a pull request?

No

Code of Conduct

Yes

ExE-Boss avatar May 17 '22 08:05 ExE-Boss

@ExE-Boss can you post a minimal example which uses the annotation and causes the hint to not work?

mbien avatar Nov 19 '23 17:11 mbien

@mbien Any existing case where a non‑TYPE_USE @CheckForNull, @NonNull, or @Nullable annotation is replaced with a TYPE_USE one.

Simply add @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE) to all the @interface test cases in NPECheckTest.java and they behave as if no nullity annotation was present.

ExE-Boss avatar Oct 03 '24 13:10 ExE-Boss

Now that JSpecify 1.0 has been released, this is probably more important than ever.

ExE-Boss avatar Nov 04 '24 20:11 ExE-Boss