View Javadoc
1   package com.puppycrawl.tools.checkstyle.checks.coding.requirethis;
2   
3   import java.awt.Toolkit;
4   import java.io.ByteArrayInputStream;
5   import java.io.IOException;
6   import java.io.InputStream;
7   
8   public class InputRequireThisEnumInnerClassesAndBugs {
9       int i;
10      void method1() {
11          i = 3;
12      }
13  
14      void method2(int i) {
15          i++;
16          this.i = i;
17          method1();
18          try {
19              this.method1();
20          }
21          catch (RuntimeException e) {
22              e.toString();
23          }
24          this.i--;
25  
26          Integer.toString(10);
27      }
28  
29      <T> void method3()
30      {
31          i = 3;
32      }
33  
34      void method4() {
35          this.<String>method3();
36          this.<I>method3();
37      }
38      int I = 0;
39      private class I {}
40  }
41  //  enum
42  enum MyEnum
43  {
44      A,
45      B
46      {
47          void doSomething()
48          {
49              z = 1;
50          }
51      };
52  
53      int z;
54      private MyEnum()
55      {
56          z = 0;
57      }
58  }
59  
60  class Bug2123003 {
61      @Rock(band = "GnR")
62      private String band;
63      
64      class Inner {
65          @Rock(band = {"GnR"})
66          private String band;
67      }
68      
69      class Inner2 {
70          @Rock(band = {(true) ? "GnR" : "Tool"})
71          private String band;
72      }
73      /*     \m/(>.<)\m/     */
74      @interface Rock {
75          String[] band() default "Metallica";
76      }
77  }
78  
79  class Bug1155921 {
80      private static int CONST = 1;
81      private static int static_method() {
82          return 1;
83      }
84  
85      private int method1() {
86          return CONST;
87      }
88  
89      private int method2() {
90          return static_method();
91      }
92  }
93  
94  interface Issue155 {
95      String BASE = "A";
96      String EXT = BASE + "B";
97  }
98  
99  class Issue257 {
100     public void foo() {
101         try (final InputStream foo = new ByteArrayInputStream(new byte[512])) {
102             foo.read();
103         }
104         catch (final IOException e) {
105             e.getCause();
106         }
107     }
108 }
109 
110 class Issue2240 {
111     int i;
112     void foo() {
113         i++;
114         i++; int i = 1; i++;
115         instanceMethod();
116     }
117     void instanceMethod() {};
118 
119     class Nested {
120         void bar() {
121             instanceMethod();
122             i++;
123         }
124     }
125 }
126 
127 class Issue2539{
128     void foo(int i) {}
129     static void foo(double i) {}
130     void foo() {}
131 
132     void bar() {
133         foo(1);
134         foo();
135     }
136 }
137 class NestedRechange {
138     final String s = "";
139 
140     NestedRechange() {
141         String s = "t";
142         s = s.substring(0);
143     }
144 
145     private static class NestedStatic {
146         static final String s = "";
147 
148         public void method() {
149             s.substring(0);
150         }
151     }
152 }
153 class NestedFrames {
154     int a = 0;
155     int b = 0;
156 
157     public int oneReturnInMethod2() {
158         for (int i = 0; i < 10; i++) {
159             int a = 1;
160             if (a != 2 && true) {
161                 if (true | false) {
162                     if (a - a != 0) {
163                         a += 1;
164                     }
165                 }
166             }
167         }
168         return a + a * a;
169     }
170 
171     public int oneReturnInMethod3() {
172         for (int b = 0; b < 10; b++) {
173         }
174         return b + b * b;
175     }
176 }