1
2
3
4
5
6
7
8
9 package com.puppycrawl.tools.checkstyle.checks.coding.fallthrough;
10
11 public class InputFallThrough3
12 {
13 void method(int i, int j, boolean cond) {
14 while (true) {
15 switch (i) {
16 case 0:
17 case 1:
18 i++;
19 break;
20 case 2:
21 i++;
22 case 3:
23 i++;
24 break;
25 case 4:
26 return;
27 case 5:
28 throw new RuntimeException("");
29 case 6:
30 continue;
31 case 7: {
32 break;
33 }
34 case 8: {
35 return;
36 }
37 case 9: {
38 throw new RuntimeException("");
39 }
40 case 10: {
41 continue;
42 }
43 case 11: {
44 i++;
45 }
46 case 12:
47 if (false)
48 break;
49 else
50 break;
51 case 13:
52 if (true) {
53 return;
54 }
55 case 14:
56 if (true) {
57 return;
58 } else {
59
60 }
61 case 15:
62 do {
63 System.identityHashCode("something");
64 return;
65 } while(true);
66 case 16:
67 for (int j1 = 0; j1 < 10; j1++) {
68 String.valueOf("something");
69 return;
70 }
71 case 17:
72 while (true)
73 throw new RuntimeException("");
74 case 18:
75 while(cond) {
76 break;
77 }
78 case 19:
79 try {
80 i++;
81 break;
82 } catch (RuntimeException e) {
83 break;
84 } catch (Error e) {
85 return;
86 }
87 case 20:
88 try {
89 i++;
90 break;
91 } catch (RuntimeException e) {
92 } catch (Error e) {
93 return;
94 }
95 case 21:
96 try {
97 i++;
98 } catch (RuntimeException e) {
99 i--;
100 } finally {
101 break;
102 }
103 case 22:
104 try {
105 i++;
106 break;
107 } catch (RuntimeException e) {
108 i--;
109 break;
110 } finally {
111 i++;
112 }
113 case 23:
114 switch (j) {
115 case 1:
116 continue;
117 case 2:
118 return;
119 default:
120 return;
121 }
122 case 24:
123 switch (j) {
124 case 1:
125 continue;
126 case 2:
127 break;
128 default:
129 return;
130 }
131 default:
132
133 i++;
134 }
135 }
136 }
137
138
139
140
141 void methodFallThru(int i, int j, boolean cond) {
142 while (true) {
143 switch (i) {
144 case -1:
145
146 case 0:
147 case 1:
148 i++;
149 break;
150 case 2:
151 i++;
152
153 case 3:
154 i++;
155 break;
156 case 4:
157 return;
158 case 5:
159 throw new RuntimeException("");
160 case 6:
161 continue;
162 case 7: {
163 break;
164 }
165 case 8: {
166 return;
167 }
168 case 9: {
169 throw new RuntimeException("");
170 }
171 case 10: {
172 continue;
173 }
174 case 11: {
175 i++;
176 }
177
178 case 12:
179 if (false)
180 break;
181 else
182 break;
183 case 13:
184 if (true) {
185 return;
186 }
187 case 14:
188 if (true) {
189 return;
190 } else {
191
192 }
193
194 case 15:
195 do {
196 System.identityHashCode("something");
197 return;
198 } while(true);
199 case 16:
200 for (int j1 = 0; j1 < 10; j1++) {
201 String.valueOf("something");
202 return;
203 }
204 case 17:
205 while (cond)
206 throw new RuntimeException("");
207 case 18:
208 while(cond) {
209 break;
210 }
211
212 case 19:
213 try {
214 i++;
215 break;
216 } catch (RuntimeException e) {
217 break;
218 } catch (Error e) {
219 return;
220 }
221 case 20:
222 try {
223 i++;
224 break;
225 } catch (RuntimeException e) {
226 } catch (Error e) {
227 return;
228 }
229
230 case 21:
231 try {
232 i++;
233 } catch (RuntimeException e) {
234 i--;
235 } finally {
236 break;
237 }
238 case 22:
239 try {
240 i++;
241 break;
242 } catch (RuntimeException e) {
243 i--;
244 break;
245 } finally {
246 i++;
247 }
248
249 case 23:
250 switch (j) {
251 case 1:
252 continue;
253 case 2:
254 return;
255 default:
256 return;
257 }
258 case 24:
259 i++;
260 case 25:
261 i++;
262 break;
263
264 case 26:
265 switch (j) {
266 case 1:
267 continue;
268 case 2:
269 break;
270 default:
271 return;
272 }
273
274 default:
275
276 i++;
277
278 }
279 }
280 }
281
282
283 void methodFallThruCC(int i, int j, boolean cond) {
284 while (true) {
285 switch (i){
286 case 0:
287 i++;
288
289 case 1:
290 i++;
291
292 case 2: {
293 i++;
294 }
295
296 case 3:
297 i++;
298 case 4:
299 break;
300 case 5:
301 i++;
302
303 }
304 }
305 }
306
307
308 void methodFallThruC(int i, int j, boolean cond) {
309 while (true) {
310 switch (i){
311 case 0:
312 i++;
313
314 case 1:
315 i++;
316
317 case 2:
318 i++;
319 case 3:
320 break;
321 case 4:
322 i++;
323
324 }
325 }
326 }
327
328
329 void methodFallThruC2(int i, int j, boolean cond) {
330 while (true) {
331 switch (i){
332 case 0:
333 i++;
334
335 case 1:
336 i++;
337
338 case 2:
339 i++;
340 case 3:
341 break;
342 case 4:
343 i++;
344
345 }
346 }
347 }
348
349
350 void methodFallThruCOtherWords(int i, int j, boolean cond) {
351 while (true) {
352 switch (i){
353 case 0:
354 i++;
355
356 case 1:
357 i++;
358
359 case 2:
360 i++;
361 case 3:
362 break;
363 case 4:
364 i++;
365
366 }
367 }
368 }
369
370
371 void methodFallThruCCustomWords(int i, int j, boolean cond) {
372 while (true) {
373 switch (i){
374 case 0:
375 i++;
376
377 case 1:
378 i++;
379
380 case 2:
381 i++;
382 case 3:
383 break;
384 case 4:
385 i++;
386
387 }
388 }
389 }
390
391 void methodFallThruLastCaseGroup(int i, int j, boolean cond) {
392 while (true) {
393 switch (i){
394 case 0:
395 i++;
396 }
397 switch (i){
398 case 0:
399 i++;
400
401 }
402 switch (i){
403 case 0:
404 i++;
405 }
406 }
407 }
408
409 void method1472228(int i) {
410 switch(i) {
411 case 2:
412
413 break;
414 default:
415 }
416 }
417
418 void nestedSwitches() {
419 switch (hashCode()) {
420 case 1:
421 switch (hashCode()) {
422 case 1:
423 }
424 default:
425 }
426 }
427
428 void nextedSwitches2() {
429 switch(hashCode()) {
430 case 1:
431 switch(hashCode()){}
432 case 2:
433 System.lineSeparator();
434 break;
435 }
436 }
437
438 void ifWithoutBreak() {
439 switch(hashCode()) {
440 case 1:
441 if (true) {
442 System.lineSeparator();
443 }
444 case 2:
445 System.lineSeparator();
446 break;
447 }
448 }
449
450 void noCommentAtTheEnd() {
451 switch(hashCode()) {
452 case 1: System.lineSeparator();
453
454 case 2:
455 System.lineSeparator();
456 break;
457 }
458 }
459
460 void synchronizedStatement() {
461 switch (hashCode()) {
462 case 1:
463 synchronized (this) {
464 break;
465 }
466 case 2:
467
468 if (true) {
469 synchronized (this) {
470 break;
471 }
472 } else {
473 synchronized (this) {
474 break;
475 }
476 }
477 case 3:
478 synchronized (this) {
479 }
480
481 default:
482 break;
483 }
484 }
485
486 void multipleCasesOnOneLine() {
487 int i = 0;
488 switch (i) {
489 case 0: case 1: i *= i;
490 case 2: case 3: i *= i;
491 case 4: case 5: i *= i;
492 case 6: case 7: i *= i;
493 break;
494 default:
495 throw new RuntimeException();
496 }
497 }
498 }