Type annotations in multicatch

Alex Buckley alex.buckley at oracle.com
Thu Jan 10 14:56:48 PST 2013


On 1/10/2013 2:53 PM, Werner Dietl wrote:
> Thanks for the clarification, Alex!
> So far I only looked at the start_pc and didn't notice that the
> entries differed in catch_type;

For this trivial program:

public class Exc {
   static class MyException extends Exception {}
   static class MyException2 extends Exception {}

   public static void main(String[] a) {
     try { throw new Exception(); }
     catch (MyException | MyException2 e) {}
     catch (Exception e2) {}
   }
}

I get:

Code:
      0: new           #2 // class java/lang/Exception
      3: dup
      4: invokespecial #3 // Method java/lang/Exception."<init>":()V
      7: athrow
      8: astore_1
      9: goto          13
     12: astore_1
     13: return
   Exception table:
     from    to  target type
        0     8     8   Class Exc$MyException
        0     8     8   Class Exc$MyException2
        0     8    12   Class java/lang/Exception

Two exception_table entries for the same try block, with different 
catch_type's.

Alex


More information about the type-annotations-dev mailing list