class Demo { static void A() { throw new RuntimeException (); } static void B() { try { A(); } catch (IOException e){ System.out.println ("B caught IOException"); } } public static void main (String[] args) { try { B(); } catch (NullPointerException e) { System.out.println ("main caught NullPointerException"); } } }
try { } catch (YourException ex) { throw new MyException (ex); }[Not really "finally" related.]
Method void main(java.lang.String[]) 0 ldc #1 <Integer 400000> 2 newarray int 4 astore_1 5 iconst_0 6 istore_2 7 goto 17 // begin loop 10 aload_1 11 iload_2 12 iload_2 13 iastore 14 iinc 2 1 17 iload_2 // loop test 18 aload_1 19 arraylength 20 if_icmplt 10 // repeat loop, if not finished 23 goto 27 // jump over handler 26 pop // handler -- do nothing 27 return Exception table: from to target type 5 23 26 <Class java.lang.Exception>
Method void main(java.lang.String[]) 0 ldc #1 <Integer 400000> 2 newarray int 4 astore_1 5 iconst_0 6 istore_2 7 goto 17 // begin loop 10 aload_1 11 iload_2 12 iload_2 13 iastore 14 iinc 2 1 17 iload_2 // loop test 18 aload_1 19 arraylength 20 if_icmplt 10 // repeat loop, if not finished 23 return
Method void main(java.lang.String[]) 0 ldc #1 <Integer 400000> 2 newarray int 4 astore_1 5 iconst_0 6 istore_2 7 goto 24 // begin loop 10 aload_1 11 iload_2 12 iload_2 13 iastore 14 goto 21 // jump over handler 17 pop // handler -- do nothing 18 goto 21 21 iinc 2 1 24 iload_2 // loop test 25 aload_1 26 arraylength 27 if_icmplt 10 // repeat loop, if not finished 30 return Exception table: from to target type 10 14 17 >Class java.lang.Exception>