title: Null analysis in eclipse compatibility break between 7 and 8
body: <p>I have encountered strange behaviour of nullcheck analysis under Spring tool suite 3.6.2 (Eclipse clon) on windows 7 64bit with Oracle java 8u25. The same maven project with java 7 source compatibility successfully finds NPE error in eclipse, but when I change compilation version in maven to java 1.8, the eclipse is unable to find this error.</p>
  
  <p>My nullcheck analysis configuration in Eclipse (Java->Compiler->Errors/Warnings->Null analysis) is:
  Include asserts in null analysis true
  Enable annotation based analysis true
  NotNull custom annotation is properly set to javax.validation.constraints.NotNull
  etc. (everything seems to be OK, as it works under java 7)</p>
  
  <p>My maven pom is here <a href="http://pastebin.com/pF1yJSG2" rel="nofollow">http://pastebin.com/pF1yJSG2</a> , as mentioned above when java.version in pom is 1.7 null check works, when is 1.8 null check does not work.</p>
  
  <p>Sample source code is:</p>
  
  <pre><code>package test.nullcheckbug.core;
  
  import javax.validation.constraints.NotNull;
  
  public class Program {
  
  /**
   * This will fail to compile under java 7 (null analysis works in STS
   * 3.6.2). But under java 8 it does not show error in Eclipse Markers -
   * static analysis does not work ?!
   * 
   * @return null which is not allowed
   */
  @NotNull
  public String fail() {
      return null;
  }
  
  /**
   * Simple main.
   * 
   * @param args
   *            ignored args
   */
  public static void main(String[] args) {
  }
  }
  </code></pre>
  
  <p>Does anybody know where is problem and how to enable nullcheck to work under jdk 1.8 compatibility ?</p>
  
  <p>EDITED:
  Maven seems to be not involved. The same problem simulated on non maven project with the same source code and compatibility level of compiler set to 1.7. Is it a bug ?</p>
  
  <p>EDITED-2:
  After more examination I have found that the following difference in annotation makes difference : java.lang.annotation.ElementType.TYPE_USE , when annotation does not have this, the nullcheck is not detected under Java 8, but is detected under Java 7.
  But why ?! Why there is so different behaviour ?!</p>
  
  <p>EDITED-3:
  After research from MartinLippert and tested by me it seems that nullcheck API has drastically changed between java 7 and java 8. Null detection requires (as seen from version 2.0 of eclipse libraries) java.lang.annotation.ElementType.TYPE_USE, the types @Target(value={METHOD,FIELD,ANNOTATION_TYPE,CONSTRUCTOR,PARAMETER}) are ignored in analysis. SO THE QUESTION IS NOW AS FOLLOWS: WHY NULL ANALYSIS UNDER JAVA 8 REQUIRES AND WORKS ONLY UNDER NEW ELEMENT TYPE ? (I understand that with java 8 it is good to fully utilise new language features, but why was needed to break compatibility ? For example javax.validation @NotNull is now unusable as nullchecking annotation :-((( )</p>