This repository was archived by the owner on Jul 12, 2023. It is now read-only.
forked from polyglot-compiler/JLang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTryFinally.java
114 lines (104 loc) · 3.19 KB
/
TryFinally.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
class TryFinally {
public static void main(String[] args) {
empty();
simpleReturn();
simpleBreak();
simpleContinue();
nestedReturn();
crazy();
}
static void empty() {
try {}
finally {}
}
static void simpleReturn() {
try {
System.out.println("simple return try");
if (true) return;
} finally {
System.out.println("simple return finally");
}
System.out.println("simple return end");
}
static void simpleBreak() {
label: try {
System.out.println("simple break try");
break label;
} finally {
System.out.println("simple break finally");
}
while (true) {
try {
inner: if (true) {
break inner;
}
System.out.println("simple break loop try");
break;
} finally {
System.out.println("simple break loop finally");
}
}
System.out.println("simple break end");
}
static void simpleContinue() {
for (int i = 0; i < 2; ++i) {
try {
for (int j = 0; j < 1; ++j)
if (j == 0)
continue;
System.out.println("simple continue try");
continue;
} finally {
System.out.println("simple continue finally");
}
}
System.out.println("simple continue end");
}
static void nestedReturn() {
try {
try {
System.out.println("nested return try");
if (true) return;
} finally {
System.out.println("nested return inner");
}
} finally {
System.out.println("nested return outer");
}
System.out.println("nested return end");
}
static void crazy() {
while (true) {
try {
try {
System.out.println("crazy inner try");
if (true) break;
} finally {
System.out.println("crazy inner finally");
}
System.out.println("crazy outer try end");
} finally {
System.out.println("crazy outer finally");
try {
try {
System.out.println("crazy second inner try");
if (true) {
while (true) {
return;
}
}
} finally {
System.out.println("crazy second inner finally");
if (true) break;
}
System.out.println("crazy second inner try end");
} finally {
System.out.println("crazy second outer try finally");
}
System.out.println("crazy second outer finally end");
}
System.out.println("crazy loop end");
}
System.out.println("crazy end");
}
}