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