1
2
3
4
5
6 package integration.tests.other.control.structures;
7
8 public final class SwitchStatements {
9 void switchStatementWithSparseCasesAndDefault(char c) {
10 switch (c) {
11 case 'A':
12 System.gc();
13 break;
14 case 'f': {
15 boolean b = true;
16 System.gc();
17 System.runFinalization();
18 break;
19 }
20 case '\0':
21 return;
22 default:
23 throw new IllegalArgumentException();
24 }
25 }
26
27 void anotherSwitchStatementWithSparseCasesAndDefault(char c) {
28 switch (c) {
29 case 'B':
30 System.gc();
31 break;
32 default:
33 System.runFinalization();
34 }
35 }
36
37 void switchStatementWithCompactCasesAndDefault(int i) {
38 switch (i) {
39 case 1:
40 System.gc();
41 break;
42 case 2: {
43 boolean b = true;
44 System.gc();
45 System.runFinalization();
46 break;
47 }
48 case 4:
49 return;
50 default:
51 throw new IllegalArgumentException();
52 }
53 }
54
55 void anotherSwitchStatementWithCompactCasesAndDefault(int i) {
56
57 switch (i) {
58 case 1: System.gc(); break;
59 default: System.runFinalization();
60 }
61
62 }
63
64 void switchStatementWithSparseCasesAndNoDefault(char c) {
65 switch (c) {
66 case 'A':
67 System.gc();
68 break;
69 case 'f':
70 System.runFinalization();
71 break;
72 }
73 }
74
75 boolean switchStatementWithCompactCasesAndNoDefault(int i) {
76 boolean b = true;
77
78
79 switch (i) {
80 case 1: System.gc(); return b;
81 case 2: System.runFinalization(); return b;
82 case 4: b = false;
83 }
84
85
86 return b;
87 }
88
89 char switchStatementWithExitInAllCases(int i) {
90 switch (i) {
91 case 1:
92 return 'a';
93 case 2:
94 return 'b';
95 default:
96 throw new IllegalArgumentException();
97 }
98 }
99
100 int switchOnString(String s, boolean b) {
101 switch (s) {
102 case "A":
103 return 1;
104 default:
105 return b ? 2 : 3;
106 }
107 }
108 }