View Javadoc
1   /*
2   FallThrough
3   checkLastCaseGroup = (default)false
4   reliefPattern = Continue with next case
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.coding.fallthrough;
10  
11  public class InputFallThroughWithoutReliefPattern {
12    void method(int i, boolean cond) {
13      while (true) {
14        switch (i) {
15          case 0:
16          case 1:
17            i++;
18            break;
19          case 2:
20            i++;
21          case 3: // violation 'Fall\ through from previous branch of the switch statement.'
22            i++;
23            break;
24          case 4:
25            return;
26          case 5:
27            throw new RuntimeException("");
28          case 6:
29            continue;
30          case 7: {
31            break;
32          }
33          case 8: {
34            return;
35          }
36          case 9: {
37            throw new RuntimeException("");
38          }
39          case 10: {
40            continue;
41          }
42          case 11: {
43            i++;
44          }
45          case 12: // violation 'Fall\ through from previous branch of the switch statement.'
46            if (false)
47              break;
48            else
49              break;
50          case 13:
51            if (true) {
52              return;
53            }
54          case 14: // violation 'Fall\ through from previous branch of the switch statement.'
55            if (true) {
56              return;
57            } else {
58              //do nothing
59            }
60          case 15: // violation 'Fall\ through from previous branch of the switch statement.'
61            do {
62              System.identityHashCode("something");
63              return;
64            } while (true);
65          case 16:
66            for (int j1 = 0; j1 < 10; j1++) {
67              String.valueOf("something");
68              return;
69            }
70          case 17:
71            while (true)
72              throw new RuntimeException("");
73          case 18:
74            while (cond) {
75              break;
76            }
77          case 19: // violation 'Fall\ through from previous branch of the switch statement.'
78            try {
79              i++;
80              break;
81            } catch (RuntimeException e) {
82              break;
83            } catch (Error e) {
84              return;
85            }
86          case 20:
87            try {
88              i++;
89              break;
90            } catch (RuntimeException e) {
91            } catch (Error e) {
92              return;
93            }
94          case 21: // violation 'Fall\ through from previous branch of the switch statement.'
95            try {
96              i++;
97            } catch (RuntimeException e) {
98              i--;
99            } finally {
100             break;
101           }
102         case 22:
103           try {
104             i++;
105             break;
106           } catch (RuntimeException e) {
107             i--;
108             break;
109           } finally {
110             i++;
111           }
112         default:
113           i++;
114       }
115     }
116   }
117 }