View Javadoc
1   /*
2   SuppressWarnings
3   format = ^unchecked$*
4   tokens = CLASS_DEF,METHOD_DEF
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.annotation.suppresswarnings;
10  
11  import java.lang.annotation.Documented;
12  
13  // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
14  @SuppressWarnings("unchecked")
15  public class InputSuppressWarningsSingle4
16  {
17      @SuppressWarnings("   ")
18      class Empty {
19  
20          @SuppressWarnings("")
21          public Empty() {
22  
23          }
24      }
25  
26      @SuppressWarnings("unused")
27      enum Duh {
28  
29          @SuppressWarnings("unforgiven")
30          D;
31  
32          public static void foo() {
33  
34              @SuppressWarnings("unused")
35              Object o = new InputSuppressWarningsSingle4() {
36  
37                  @Override
38                  @SuppressWarnings("unchecked")
39                  // violation above, 'The warning 'unchecked' cannot be suppressed at this location'
40                  public String toString() {
41                      return "";
42                  }
43              };
44          }
45      }
46  
47      @SuppressWarnings("abcun")
48      @Documented
49      @interface Sweet {
50          int cool();
51      }
52  
53      @Documented
54      @SuppressWarnings("abcun")
55      @interface MoreSweetness {
56  
57          @SuppressWarnings("unused")
58          int cool();
59      }
60  
61      public class Junk {
62  
63          @SuppressWarnings("")
64          int a = 1;
65  
66          @SuppressWarnings("unchecked")
67          @Deprecated
68          int b = 1;
69          void doFoo(String s, @SuppressWarnings("unchecked")String y) {
70  
71          }
72      }
73  
74      // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
75      @SuppressWarnings((false) ? "unchecked" : "")
76      class Cond {
77  
78          @SuppressWarnings((false) ? "" : "unchecked")
79          public Cond() {
80  
81          }
82  
83          // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
84          @SuppressWarnings((false) ? (true) ? "   " : "unused" : "unchecked")
85          public void aCond1() {
86  
87          }
88  
89          // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
90          @SuppressWarnings((false) ? "unchecked" : (true) ? "   " : "unused")
91          public void aCond2() {
92  
93          }
94  
95          // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
96          @java.lang.SuppressWarnings((false) ? "unchecked" :
97                  ("" == "") ? (false) ? (true) ? "" : "foo" : "    " : "unused")
98          public void seriously() {
99  
100         }
101     }
102 }