title: Unreachable code error vs. dead code warning in Java under Eclipse?
body: <p>Does anyone know why:</p>
  
  <pre><code>public void foo()
  {
      System.out.println("Hello");
      return;
      System.out.println("World!");
  }
  </code></pre>
  
  <p>Would be reported as an "unreachable error" under Eclipse, but</p>
  
  <pre><code>public void foo()
  {
      System.out.println("Hello");
      if(true) return;
      System.out.println("World!");
  }
  </code></pre>
  
  <p>Only triggers a "Dead code" warning?</p>
  
  <p>The only explanation I can think of is that the Java compiler only flags the first, and that some extra analysis in Eclipse figures out the second. However, if that is the case, why can't the Java compiler figure out this case at compile time?</p>
  
  <p>Wouldn't the Java compiler figure out at compile time that the if(true) has no effect, thus yielding bytecode that is essentially identical? At what point is the reachable code analysis applied? </p>
  
  <p>I guess a more general way to think of this question is: "when is the reachable code analysis applied"? In the transformation of the second Java code fragment to the final bytecode, I am sure that at some point the "if(true)" runtime equivalent is removed, and the representations of the two programs become identical. Wouldn't the Java compiler then apply its reachable code analysis again? </p>