1 package testdata; 2 3 public class TryCatchFinally { 4 method()5 public static void method() { 6 int count = 0; 7 try { 8 if (true) { 9 throw new NullPointerException(); 10 } 11 throw new AssertionError(); 12 } catch (IllegalStateException e) { 13 throw new AssertionError(); 14 } catch (NullPointerException expected) { 15 count++; 16 } catch (RuntimeException e) { 17 throw new AssertionError(); 18 } finally { 19 count++; 20 } 21 22 if (count != 2) { 23 throw new AssertionError(); 24 } 25 } 26 } 27