Java: Spotbugs-Annotation `@CheckForNull` deprecated. What to use instead?

73 Views Asked by At

In order to help my static code analysis, I have used the @CheckForNull -Annotation from spotbugs: edu.umd.cs.findbugs.annotations.CheckForNull

It has come to my awareness that this annotation though still working, is officially deprecated. What would you use in terms of best practice instead?

Best wishes Abegail

Searched google and forums, but cannot find an answer.

1

There are 1 best solutions below

6
mernst On

Answered here: What @Nullable to use in Java (as of 2023/JDK21)?

In brief:

The best choice for the @Nullable and @NonNull annotation remains that of the Checker Framework. It is the de facto standard (import org.checkerframework.checker.nullness.qual... appears in 95k files on GitHub), is recognized by the widest variety of tools, is a superset of most other nullness annotations, and has a clear, standard semantics.