title: Catch exceptions which are not thrown locally?
body: <p>My question is related to syntactic behavior of the try catch block</p>
  
  <p>Empty try block with a catch as this</p>
  
  <pre><code>void fun() {
      try {}
      catch(Exception e) {}
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>try {}
  catch(ArrayIndexOutOfBoundsException e) {}
  </code></pre>
  
  <p>compiles well but the compiler complains with</p>
  
  <pre><code>try {}
  catch(IOException e) {}
  </code></pre>
  
  <p>Why does the compiler allow catching anything that is of type Exception or RuntimeException whereas it complains for unreachable code with checked exceptions? Is it because the JVM code can throw those types? How could the JVM possibly throw ArrayIndexOutOfBoundsException in an empty try block?</p>