1 package test.java.semantics;
3 import java.io.FileNotFoundException;
5 class finally_behavior_test
9 public finally_behavior_test()
13 public int funkyTown() throws FileNotFoundException
16 // we should never get here. it should always raise an exception.
17 System.out.println("where did you put it?");
19 throw new FileNotFoundException("is it larger than a breadbox?");
24 public void runTest() throws Throwable
27 int zooty = funkyTown();
28 System.out.println("zooty is " + zooty + " but how did we get here???");
29 } catch (Throwable cause) {
30 System.out.println("caught exception, now will rethrow.");
33 System.out.println("still got to finally, our assumptions are safe.");
37 public static void main(String s[]) throws Exception
39 // we are asserting that the finally clause of an exception handler will still
40 // fire when an exception is raised in the catch clause. otherwise, all our
41 // assumptions about being able to use finally properly are thrown out the window.
42 finally_behavior_test tony = new finally_behavior_test();
45 } catch (Throwable cause) {
48 System.out.println("Hey, did the finally clause say it ran above?");
49 System.out.println("If so, great. If not, we've got problems.");