title: Catching multiple exceptions in Java-8
body: <p>While trying out the <em>multi-catch</em> feature I found in my <code>m1()</code> method everything is working fine as expected.</p>
  
  <p>However, in <code>m2()</code> the same code does not compile. I have just changed the syntax to reduce the number of lines of code.</p>
  
  <pre><code>public class Main {
  
      public int m1(boolean bool) {
          try {
              if (bool) {
                  throw new Excep1();
              }
              throw new Excep2();
              //This m1() is compiling  abs fine.
          } catch (Excep1 | Excep2 e) {
              return 0;
          }
      }
  
      public int m2(boolean b) {
          try {
              throw b ? new Excep1() : new Excep2();
              //This one is not compiling.
          } catch (Excep1 | Excep2 e) {
              return 0;
          }
      }
  
      private static interface I {
      }
  
      private static class Excep1 extends Exception implements I {
      }
  
      private static class Excep2 extends Exception implements I {
      }
  }
  </code></pre>
  
  <p>Why doesn't method <code>m2()</code> compile?</p>