Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/com/sun/jdi/ControlFlow.java
41149 views
1
/* /nodynamiccopyright/ */ // hard coded linenumbers in other tests - DO NOT CHANGE
2
/*
3
* Debuggee which exercises various types of control flow
4
*/
5
6
class ControlFlow {
7
boolean b = true;
8
int n = 22;
9
10
public static void main(String args[]) throws Exception {
11
(new ControlFlow()).go();
12
}
13
14
void go() throws Exception {
15
if (b) {
16
System.out.println("if, no else");
17
}
18
19
if (b) {
20
System.out.println("if branch");
21
} else {
22
throw new Exception("Wrong branch!?");
23
}
24
25
if (!b) {
26
throw new Exception("Wrong branch!?");
27
} else {
28
System.out.println("else branch");
29
}
30
31
try {
32
throw new Exception();
33
} catch (Exception e) {
34
System.out.println("caught exception");
35
} finally {
36
System.out.println("finally");
37
}
38
39
// This isn't control flow at the source level, but it is at the bytecode level
40
synchronized (this) {
41
System.out.println("synchronized");
42
}
43
44
45
for (int i = 0; i < n; i++) {
46
System.out.println("Loop iteration: " + (i+1) + "/" + n);
47
}
48
49
switch (n) {
50
case 0:
51
throw new Exception("Wrong branch!?");
52
case 1:
53
throw new Exception("Wrong branch!?");
54
case 2:
55
throw new Exception("Wrong branch!?");
56
case 3:
57
throw new Exception("Wrong branch!?");
58
case 22:
59
System.out.println("switch case");
60
break;
61
default:
62
throw new Exception("Wrong branch!?");
63
}
64
65
switch (n) {
66
case 0:
67
throw new Exception("Wrong branch!?");
68
case 1:
69
throw new Exception("Wrong branch!?");
70
case 2:
71
throw new Exception("Wrong branch!?");
72
case 3:
73
throw new Exception("Wrong branch!?");
74
default:
75
System.out.println("switch default");
76
break;
77
}
78
}
79
}
80
81