Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 2.5 KB

File metadata and controls

25 lines (19 loc) · 2.5 KB

APACHE v2 License Latest Release Javadocs

jetbrains-runtime-nullability-annotations

The well-known Jetbrains nullability annotations, but with RUNTIME retention

<dependency>
  <groupId>com.github.bbottema</groupId>
  <artifactId>jetbrains-runtime-annotations</artifactId>
  <version>2.0.0</version>
  <scope>provided</scope>
</dependency>

Why

There are currently no nullability annotations available that are available for reflection in runtime. The community used to have the javax.annotation.Nullable from FindBugs' and later SpotBugs' JSR305 implementation, but as that uses the same packages as the JDK, with Java's modularization, this can cause the split-package problem.

Modern IDE's natively handle these annotations and common static analyses (like the Maven SpotBugs plugin) understand these annotations, but are limited to a specific set of known common packages or certain Java class names. The Jetbrains annotations, and possible the Eclipse annotations, are the most neutral and light-weight libraries available that are supported this way. Google's Checker Qual brings a lot of baggage and the others are focussed on Android or are very old.

That leaves us with the Jetbrains annotations, but they are limited to CLASS retention and its developers have no plans to change this. They in fact suggest to recompile them with RUNTIME retention.

How

This library simply copies the source code for the Jetbrains nullability annotations (only @NotNull and @Nullable) and changes the retention from CLASS to RUNTIME