there is no standard @nonnull annotation. creating such an annotation was the goal of jsr 305, which has been abandoned for a long time. there will not be a standard @nonnull annotation until jsr 305 is reconstituted. oracle has no current plans to do so. (jee annotations are outside the scope of jsr 305.)

for futureproofing, the most important factor to consider is whether the annotation is a type annotation or a declaration annotation. because @nonnull states a property of the variable's value rather than of the variable itself, it should be a type annotation. being a type annotation also lets the annotation be written on more locations, as in list<@nonnull string>.

you can determine whether an annotation is a type annotation by looking at the @target meta-annotation on the annotation's definition. as of this writing, it seems that only the checker framework and eclipse versions are type annotations, so i would choose them over the ones that are declaration annotations. note that the developers of any of the other annotations could update them to be type annotations as well; i don't know of their plans.

the only downside is that using a type annotation requires use of a java 8 compiler. the checker framework has mechanisms for letting code containing its annotations be compiled by a java 7 compiler.

Related Query

More Query from same tag