title: Why can not Java multi-catch deal with types that is related by subclassing?
body: <p>Here is a piece of code that shall not compile:</p>
  
  <pre><code>void multiCatch()
  {
      try {
          throwIOFile();
      }
      // FileNotFoundException extends IOException, hence this
      // does not compile ("alternatives" related by sub classing):
      catch (IOException | FileNotFoundException e) { }
  }
  
  void throwIOFile() throws IOException, FileNotFoundException
  {}
  </code></pre>
  
  <p>Everything works like a charm had not the exception types been related by sub classing. If you swap the <code>IOException</code> in my code snippet for say.. <code>SQLException</code>, it works. The <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html">specification</a> reads:</p>
  
  <blockquote>
    <p>It is a compile-time error if a union of types contains two
    alternatives Di and Dj (i ≠ j) where Di is a subtype of Dj.</p>
  </blockquote>
  
  <p>I can not understand the rationale behind this. Granted, the multi-catch in my example is completely redundant since I could just as well catch an <code>IOException</code> only. But what would be the <strong>harm</strong> in making my code snippet legal? Surely there has to be a harm for a practice to become illegal?</p>