1
2
3
4
5
6 package integration.tests;
7
8
9
10
11 @SuppressWarnings("ControlFlowStatementWithoutBraces")
12 public final class IfElseStatements {
13
14
15
16
17
18
19
20 void simpleIf(boolean b) {
21 if (b) {
22 System.gc();
23 System.runFinalization();
24 }
25 }
26
27
28
29
30
31
32
33 void ifAndElse(boolean b) {
34 if (b) {
35 System.gc();
36 } else {
37 System.runFinalization();
38 }
39 }
40
41
42
43
44
45
46
47 void singleLineIf(boolean b) {
48
49 if (b) { System.gc(); }
50
51 }
52
53
54
55
56
57
58
59 void singleLineIfAndElse(boolean b) {
60
61 if (b) { System.gc(); } else { System.runFinalization(); }
62
63 }
64
65
66
67
68
69
70
71
72
73 void methodWithFourDifferentPathsAndSimpleLines(boolean b, int i) {
74 if (b) {
75 System.gc();
76 } else {
77 System.runFinalization();
78 }
79
80 if (i > 0) {
81 System.gc();
82 }
83 }
84
85
86
87
88
89
90
91
92
93 void methodWithFourDifferentPathsAndSegmentedLines(boolean b, int i) {
94 if (b) {
95 System.gc();
96 } else {
97 System.runFinalization();
98 }
99
100 if (i > 0) {
101 System.gc();
102 } else {
103 System.runFinalization();
104 }
105 }
106
107
108
109
110
111
112
113
114
115
116
117 boolean ifElseWithComplexBooleanCondition(boolean a, boolean b) {
118
119 if (a || b) {
120 return true;
121 }
122 return false;
123 }
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 @SuppressWarnings({ "AssignmentToMethodParameter" })
141 int returnInput(int x, boolean a, boolean b, boolean c) {
142 if (a) {
143 x++;
144 }
145
146 if (b) {
147 x--;
148 }
149
150 if (c) {
151
152 x = x;
153 }
154
155 return x;
156 }
157
158
159
160
161
162
163
164
165
166
167
168 int nestedIf(boolean a, boolean b) {
169 int i = 1;
170
171 if (a && b) {
172 i = 2;
173 }
174
175 return i;
176 }
177
178
179
180
181
182
183
184
185
186
187
188 int ifElseWithNestedIf(boolean a, boolean b) {
189 int i = 1;
190
191 if (!a) {
192 return 3;
193 }
194 if (b) {
195 i = 2;
196 }
197
198 return i;
199 }
200
201
202
203
204
205
206
207
208
209
210
211 int nestedIfElse(boolean a, boolean b) {
212 int i = 1;
213
214 if (a) {
215 if (b) {
216 i = 2;
217 } else {
218 i = 3;
219 }
220 } else if (b) {
221 i = 4;
222 }
223
224 return i;
225 }
226
227
228
229
230
231
232
233 void infeasiblePaths(boolean a) {
234 if (a) {
235 System.gc();
236 }
237
238 if (a) {
239 System.runFinalization();
240 }
241 }
242
243
244
245
246
247
248
249
250
251 int anotherSingleLineIfAndElse(boolean b) {
252
253 int r; if (b) { r = 1; } else { r = 2; } return r;
254
255 }
256
257
258
259
260
261
262
263
264
265 int yetAnotherSingleLineIfAndElse(boolean b) {
266
267 if (b) { return 1; } return 2;
268
269 }
270
271
272
273
274
275
276
277
278
279 void ifWithBooleanAndOperator(boolean b1, boolean b2) {
280 if (b1 && b2) {
281 System.gc();
282 }
283 }
284
285
286
287
288
289
290
291
292
293 void ifWithBooleanOrOperator(boolean b1, boolean b2) {
294 if (b1 || b2) {
295 System.gc();
296 }
297 }
298
299
300
301
302
303
304
305
306
307 void anotherIfWithBooleanAndOperator(boolean b1, boolean b2) {
308 if (b1 && b2) {
309 System.gc();
310 }
311 }
312
313
314
315
316
317
318
319
320
321 void ifSpanningMultipleLines(boolean b, int i) {
322
323 if (
324 b ||
325 i > 0
326 ) {
327 System.gc();
328 }
329
330 }
331
332
333
334
335
336
337
338
339
340 ClassLoader methodToBeCalledFromCustomRunnerTest(String s) {
341 instanceField = s;
342
343 if (s.isEmpty()) {
344 return null;
345 }
346
347 return getClass().getClassLoader();
348 }
349
350
351 String instanceField;
352 }