title: Which @NonNull Java annotation to use
body: <p><strong>What is the <em>best</em> 'NonNull' annotation?</strong></p>
  
  <p><strong>"Best"</strong> in the sense of</p>
  
  <ul>
  <li>Standard way e.g. future proofness (e.g. support by standard jdk etc.)</li>
  <li>Support of IDE's (shows up in java doc to indicate the usage for developers)</li>
  <li>Support by static analysis tools like findbugs</li>
  <li>Support for runtime analysis</li>
  </ul>
  
  <p>Here's how the world currently look like - any further insight is appreciated:</p>
  
  <ul>
  <li><p><strong><code>javax.validation.constraints.NotNull</code></strong> (<a href="http://docs.oracle.com/javaee/7/api/index.html?javax/validation/constraints/NotNull.html" rel="noreferrer">Docs</a>)<br>
  + javax package thus seems futureproof<br>
  - Part of JEE <strong>not</strong> JSE. In JSE need to <a href="https://stackoverflow.com/questions/2707683/how-do-i-import-javax-validation-into-my-java-se-project">import additional libs</a>.<br>
  - Not supported by static analysis tools (runtime validation only)</p></li>
  <li><p><s><strong><code>edu.umd.cs.findbugs.annotations.NonNull</code></strong></s> (<a href="http://findbugs.sourceforge.net/api/edu/umd/cs/findbugs/annotations/package-summary.html" rel="noreferrer">docs</a>)<br>
  - external library and not an <code>javax</code> package<br>
  - <a href="http://findbugs.sourceforge.net/api/edu/umd/cs/findbugs/annotations/package-summary.html" rel="noreferrer">deprecated</a> since findbugs version 3.X<br>
  + used for static analysis (by findbugs and therefore Sonar)    </p></li>
  <li><p><s><strong><code>javax.annotation.Nonnull</code></strong></s> (<a href="https://code.google.com/p/jsr-305/" rel="noreferrer">docs</a>)<br>
  + used for static analysis (in findbugs)<br>
  - <a href="https://jcp.org/en/jsr/detail?id=305" rel="noreferrer">JSR-305</a> is dormant/dead/unknown as on the <a href="https://mailman.cs.umd.edu/pipermail/findbugs-discuss/2015-October/thread.html#4237" rel="noreferrer">fb mailing list</a> indicated. The author Bill Pugh, even if directly asked, hasn't commented the state in years...</p></li>
  <li><p><s><strong><code>org.eclipse.jdt.annotation_2.0.0</code></strong></s> (<a href="https://wiki.eclipse.org/JDT_Core/Null_Analysis/Null_Contracts" rel="noreferrer">docs</a>, interesting <a href="https://www.eclipsecon.org/na2014/sites/default/files/slides/JDTEmbracesTypeAnnotations.pdf" rel="noreferrer">presentation</a>)<br>
  + used for static analysis (in eclipse not in findbugs though)<br>
  - proprietary to eclipse (didn't try to use them standalone)</p></li>
  <li><p><s><strong><code>org.jetbrains.annotations.NotNull</code></strong></s> (<a href="https://www.jetbrains.com/idea/help/nullable-and-notnull-annotations.html" rel="noreferrer">docs</a>)<br>
  + used for static analysis (in intelliJ not in findbugs though)<br>
  - proprietary to IntelliJ (but also publicly available as a jar)</p></li>
  <li><p><strong><code>lombok.NonNull</code></strong>(<a href="https://projectlombok.org/features/NonNull.html" rel="noreferrer">docs</a>)<br>
  + used to control code generation<br>
  - proprietary annotation</p></li>
  <li><p><strong><code>android.support.annotation.NonNull</code></strong> (<a href="http://tools.android.com/tech-docs/support-annotations" rel="noreferrer">docs</a>)<br>
  + static analysis in android studio<br>
  - android specific proprietary annotation</p></li>
  <li><p><strong><code>org.checkerframework.checker.nullness.qual.NonNull</code></strong> (<a href="https://checkerframework.org/api/index.html?org/checkerframework/checker/nullness/qual/NonNull.html" rel="noreferrer">docs</a>)<br>
  + <a href="https://checkerframework.org/jsr308/" rel="noreferrer">JSR308</a> implementation which is part of Java8 (which did introduce the ability to write annotations in different parts of your code, but did not introduce new annotations)<br>
  + used for static code (not findbugs though) <strong>and</strong> runtime analysis<br>
  - external lib however seems to be <a href="http://www.oracle.com/technetwork/articles/java/ma14-architect-annotations-2177655.html" rel="noreferrer">endorsed</a> by the java folks </p></li>
  </ul>
  
  <p>Currently I would tend to the <a href="https://checkerframework.org/" rel="noreferrer">Checker Framework</a> but I am looking forward for other views...</p>
  
  <p><em>[disclaimer]</em> I know the question has been asked here however was not answered (or the answer was wrong/incomplete/outdated) 
  <em>[/disclaimer]</em></p>