source: doc/theses/andrew_beach_MMath/code/ThrowOther.java@ d5f6a14

ADT ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since d5f6a14 was ea593a3, checked in by Andrew Beach <ajbeach@…>, 4 years ago

First draft of all the exception benchmarks. There is an issue with the Cforall linking.

  • Property mode set to 100644
File size: 924 bytes
Line 
1// Throw Across Other Handler
2
3class EmptyException extends Exception {}
4
5class NotRaisedException extends Exception {}
6
7public class ThrowOther {
8 static boolean should_throw = false;
9
10 private static void unwind_other(int frames)
11 throws EmptyException, NotRaisedException {
12 if (0 < frames) {
13 try {
14 unwind_other(frames - 1);
15 } catch (NotRaisedException e) {
16 // ...
17 }
18 } else {
19 if (should_throw) {
20 throw new NotRaisedException();
21 }
22 throw new EmptyException();
23 }
24 }
25
26 public static void main(String[] args) {
27 int times = 1;
28 int total_frames = 1;
29 if (0 < args.length) {
30 times = Integer.parseInt(args[0]);
31 }
32 if (1 < args.length) {
33 total_frames = Integer.parseInt(args[1]);
34 }
35
36 for (int count = 0 ; count < times ; ++count) {
37 try {
38 unwind_other(total_frames);
39 } catch (EmptyException e) {
40 // ...
41 } catch (NotRaisedException e) {
42 // ...
43 }
44 }
45 }
46}
Note: See TracBrowser for help on using the repository browser.