View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // Test case file for checkstyle.
3   // Created: 2001
4   ////////////////////////////////////////////////////////////////////////////////
5   package com.google.checkstyle.test.chapter6programpractice.rule62donotignoreexceptions;
6   
7   import java.io.*; 
8   import java.awt.Dimension;
9   import java.awt.Color;
10  
11  class Catch {
12      boolean flag;
13      void doSm() {}
14      void foo() {
15          try {
16             if (!flag) {
17                 doSm();
18             }
19          } catch (Exception e) { /* ignore */ } //ok
20          finally {/* ignore */} //ok
21      }
22  
23      void foo2() {
24          try {
25             if (!flag) {
26                 doSm();
27             }
28          } catch (Exception e) {}
29          finally {} //warn
30      }
31  
32      class Inner {
33          boolean flag;
34          void doSm() {}
35          void foo() {
36              try {
37                 if (!flag) {
38                     doSm();
39                 }
40              } catch (Exception e) { /* ignore */ } //ok
41              finally {/* ignore */} //ok
42          }
43  
44          void foo2() {
45              try {
46                 if (!flag) {
47                     doSm();
48                 }
49              } catch (Exception e) {}
50              finally {} //warn
51          }
52      }
53      
54      Inner anon = new Inner(){
55          boolean flag;
56          void doSm() {}
57          void foo() {
58              try {
59                 if (!flag) {
60                     doSm();
61                 }
62              } catch (Exception e) { /* ignore */ } //ok
63              finally {/* ignore */} //ok
64          }
65  
66          void foo2() {
67              try {
68                 if (!flag) {
69                     doSm();
70                 }
71              } catch (Exception e) {}
72              finally {} //warn
73          }
74      };
75  
76      void bar1() {
77          try {
78             if(!flag) {
79                 doSm();
80             }
81          } catch (Exception expected) {}
82      }
83  
84      void bar2() {
85          try {
86             if(!flag) {
87                 doSm();
88             }
89          } catch (Exception expected) {}
90      }
91  }