View Javadoc
1   ///////////////////////////////////////////////////////////////////////////////////////////////
2   // Test case file for checkstyle.
3   ///////////////////////////////////////////////////////////////////////////////////////////////
4   
5   package com.google.checkstyle.test.chapter4formatting.rule413emptyblocks;
6   
7   import java.io.IOException;
8   
9   /** some javadoc. */
10  public class InputEmptyBlocksAndCatchBlocksNoViolations {
11    private void foo6() {
12      try {
13        throw new IOException();
14      } catch (IOException expected) { // This is expected
15        int k = 0;
16      }
17    }
18  
19    /** some javadoc. */
20    public void testTryCatch() {
21      try {
22        int y = 0;
23        int u = 8;
24        int e = u - y;
25        return;
26      } catch (Exception e) {
27        System.identityHashCode(e);
28        return;
29      } finally {
30        return;
31      }
32    }
33  
34    /** some javadoc. */
35    public void testTryCatch3() {
36      try {
37        int y = 0;
38        int u = 8;
39        int e = u - y;
40      } catch (IllegalArgumentException e) {
41        System.identityHashCode(e); // some comment
42        return;
43      } catch (IllegalStateException ex) {
44        System.identityHashCode(ex);
45        return;
46      }
47    }
48  
49    /** some javadoc. */
50    public void testTryCatch4() {
51      int y = 0;
52      int u = 8;
53      try {
54        int e = u - y;
55      } catch (IllegalArgumentException e) {
56        System.identityHashCode(e);
57        return;
58      }
59    }
60  
61    /** some javadoc. */
62    public void setFormats() {
63      try {
64        int k = 4;
65      } catch (Exception e) {
66        Object k = null;
67        if (k != null) {
68          k = "ss";
69        } else {
70          return;
71        }
72      }
73    }
74  
75    /** some javadoc. */
76    public void testIfElse() {
77      if (true) {
78        return;
79      } else {
80        return;
81      }
82    }
83  
84    /** some javadoc. */
85    public void testIfElseIfLadder() {
86      if (true) {
87        return;
88      } else if (false) {
89        return;
90      } else {
91        return;
92      }
93    }
94  
95    /** some javadoc. */
96    public void testSwtichCase() {
97      switch (1) {
98        case 1:
99          return;
100       case 2:
101         return;
102       default:
103         return;
104     }
105   }
106 }