title: Why java does not detect unreachable catch block if I use multiple catch blocks?
body: <p>Research following method:</p>
  
  <pre><code>static private void foo()  {
          try {
              throw new FileNotFoundException();
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>This code compiles good despite last catch block actually unreachable.</p>
  
  <p>Now lets comment  <code>throw new FileNotFoundException();</code> row</p>
  
  <p>execute:</p>
  
  <p>OOOPs! we see </p>
  
  <pre><code>Unreachable catch block for FileNotFoundException. This exception is never thrown from the try statement body
  </code></pre>
  
  <p>Strange. Why does java use double standards for these situatons?  </p>
  
  <h2>update for @Peter Rader</h2>
  
  <pre><code>static private void foo(FileNotFoundException f)  {
          try {
              throw f;
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>work as well as with constructor invocation</p>
  
  <h2>update</h2>
  
  <p>I noticed that on different versions of java compiler I see different result of compiling this code.</p>
  
  <pre><code>public class RethowTest {
  
          public static void main(String[] args)  {
              try {
                  throw new FileNotFoundException();
              } catch (FileNotFoundException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  throw e;
              }
          }    
  }
  </code></pre>
  
  <p>on my local pc:
  java 1.7.0_45 - </p>
  
  <pre><code>C:\Program Files\Java\jdk1.7.0_45\bin&gt;javac D:\DNN-Project\DNN-Project\src\main\java\exceptionsAndAssertions\RethowTest.java
  D:\DNN-Project\DNN-Project\src\main\java\exceptionsAndAssertions\RethowTest.java:15: warning: unreachable catch clause
                  } catch (IOException e) {
                    ^
    thrown type FileNotFoundException has already been caught
  1 warning
  </code></pre>
  
  <p>java 1.6.0_38</p>
  
  <pre><code>D:\DNN-Project\DNN-Project\src\main\java\exceptionsAndAssertions\RethowTest.java:16: unreported exception java.io.IOException; must be caught or declared to be thrown
                      throw e;
                      ^
  1 error
  </code></pre>
  
  <p><a href="http://www.compileonline.com/compile_java_online.php" rel="nofollow">http://www.compileonline.com/compile_java_online.php</a> (Javac 1.7.0_09) -</p>
  
  <pre><code>HelloWorld.java:9: warning: unreachable catch clause
          } catch (IOException e) {
            ^
    thrown type FileNotFoundException has already been caught
  1 warning
  </code></pre>