title: Booleans, conditional operators and autoboxing
body: <p>Why does this throw <code>NullPointerException</code></p>
  
  <pre><code>public static void main(String[] args) throws Exception {
      Boolean b = true ? returnsNull() : false; // NPE on this line.
      System.out.println(b);
  }
  
  public static Boolean returnsNull() {
      return null;
  }
  </code></pre>
  
  <p>while this doesn't</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
      Boolean b = true ? null : false;
      System.out.println(b); // null
  }
  </code></pre>
  
  <p>?</p>
  
  <p>The solution is by the way to replace <code>false</code> by <code>Boolean.FALSE</code> to avoid <code>null</code> being unboxed to <code>boolean</code> --which isn't possible. But that isn't the question. The question is <em>why</em>? Are there any references in JLS which confirms this behaviour, especially of the 2nd case?</p>