View Javadoc
1   package com.puppycrawl.tools.checkstyle.grammar.antlr4;
2   
3   import java.io.BufferedReader;
4   import java.io.IOException;
5   import java.io.InputStreamReader;
6   import java.util.ArrayList;
7   import java.util.HashMap;
8   import java.util.List;
9   import java.util.Map;
10  
11  public class InputRegressionJavaClass1 {
12      //comments
13  
14      // single-line
15      /* multi on single-line */
16      /* multi
17       line */
18      /** javadoc */
19      // tab ->	<-
20  
21      // fields
22      // modifiers
23      public int f1;
24      private int f2;
25      protected int f3;
26      int f4;
27      static int f5;
28      final int f6;
29      volatile int f7;
30      transient int f8;
31      Object f9;
32  
33      // constructors
34      static {}
35      public InputRegressionJavaClass1() {f6 = 0;}
36      public InputRegressionJavaClass1(int i) {this.f6 = i;}
37      public InputRegressionJavaClass1(float f) {this((int)f);}
38      InputRegressionJavaClass1(double a) throws Exception {f6 = 0;}
39  
40      // methods
41      // modifiers
42      native void m1();
43      void m2() {}
44      synchronized void m4() {}
45      strictfp void m5() {}
46  
47      // returns
48      public int[] m6() {return null;}
49      public int m7() [] {return null;}
50  
51      // parameters
52      public void m10(String p1) {}
53      public void m11(final String p1) {}
54      public void m12(String[] p1) {}
55      public void m13(String[][] p1) {}
56      public void m14(String p1, String p2) {}
57      public void m15(String... p1) {}
58      public void m16(String[]... p1) {}
59      public void m17(int p1, String[]... p2) {}
60  
61      // throws
62      public void m18() throws Exception {}
63      public void m19() throws IOException, Exception {}
64  
65      // types
66      public <T_$> T_$ m20() {return null;}
67      public <$_T> $_T m21() {return null;}
68      public <T extends Enum<T>> void m22() {}
69      public <T> void m23() {};
70      public <T extends RuntimeException & java.io.Serializable> void m24() {}
71  
72      // annotations
73      @SuppressWarnings({})
74      public void m50() {}
75      @SuppressWarnings({"1"})
76      public void m51() {}
77      @SuppressWarnings({"1","2"})
78      public void m52() {}
79      @SuppressWarnings(value={"1"})
80      public void m53() {}
81      @SuppressWarnings(value={"1",})
82      public void m54() {}
83      @SuppressWarnings(value={"1","2"})
84      public void m55() {}
85      @InputRegressionJavaAnnotation1(m1="1", m2="2")
86      public void m56() {}
87      @ComplexAnnotation({
88              @InputRegressionJavaAnnotation1(m1 = "1", m2 = ""),
89              @InputRegressionJavaAnnotation1(m1 = "1", m2 = "")
90      })
91      public void m57() {}
92      public void m58(@Deprecated String s) {}
93      public void m59(final @Deprecated List l) {}
94  
95      // extra
96      {}
97      ;
98  
99      // instructions
100     public void instructions() throws Exception {
101         // used to let inputs compile
102         boolean b = Math.random() > 0;
103 
104         // variables and types
105         byte vbyte;
106         boolean vboolean;
107         char vchar;
108         short vshort;
109         int vint;
110         long vlong;
111         float vfloat;
112         double vdouble;
113         int[] varray;
114         int varray2[];
115         boolean test1 = true;
116 
117         // types
118         String vstring;
119         List<String> vlist;
120         Map<String, String[]> vmap;
121         int[] test2 = {};
122         List<char[]> test3;
123         Class<?> test4;
124         List<? extends InputRegressionJavaClass1> test5;
125         List<? extends List<Object>> test6;
126         List<? extends List<List<Object>>> test7;
127         List<? extends int[]> test8;
128         List<? super InputRegressionJavaClass1> test9;
129 
130         // literals
131         vboolean = true;
132         vboolean = false;
133         vchar = ' ';
134         vchar = '"';
135         vchar = '\0';
136         vchar = '\'';
137         vchar = '\n';
138         vchar = '\r';
139         vchar = '\t';
140         vchar = '\b';
141         vchar = '\f';
142         vchar = '\"';
143         vchar = '\'';
144         vchar = '\\';
145         vchar = '\00';
146         vchar = '\013';
147         vchar = '\4';
148         vchar = '\40';
149         vchar = '\u0000';
150         vchar = '\u1234';
151         vchar = '\u005C\u005C';
152         vchar = '\u005c\u005c';
153         vchar = '\uu005C\uuuuu005C';
154         vchar = '\u005cn';
155         vchar = '\u005cr';
156         vchar = '\u005ct';
157         vchar = '\u005cb';
158         vchar = '\u005cf';
159         vchar = '\u005c"';
160         vchar = '\u005c'';
161         vchar = '\u005c\';
162         vint = 0;
163         vint = -1;
164         vint = +1;
165         vint = 100_000;
166         vint = 0x00;
167         vint = 0x12345678;
168         vint = 0X9;
169         vint = 0x1234_5678;
170         vint = 0b101;
171         vint = 0B101;
172         vint = 0b1;
173         vint = 0b1_0;
174         vint = 012345670;
175         vint = 01234_5670;
176         vlong = 0L;
177         vlong = 1L;
178         vlong = 0b1L;
179         vlong = 1234567890l;
180         vlong = 1234567890L;
181         vlong = 0x0l;
182         vlong = 0xABCDEFl;
183         vlong = 0XABCDEFL;
184         vfloat = 0f;
185         vfloat = 0F;
186         vfloat = 1.1f;
187         vfloat = 1.10_1F;
188         vfloat = 0_1.1_1F;
189         vfloat = 1e0f;
190         vfloat = 1e0F;
191         vfloat = 1.0e0F;
192         vfloat = 0x2__3_34.4___AFP00_00f;
193         vdouble = 10.;
194         vdouble = .1;
195         vdouble = .1__1_1;
196         vdouble = 0.0;
197         vdouble = 1000.0;
198         vdouble = .1d;
199         vdouble = 1.D;
200         vdouble = 0_1.0d;
201         vdouble = 0_1.0D;
202         vdouble = 4e23;
203         vdouble = 4E23;
204         vdouble = 4E2_3;
205         vdouble = 0x0.0000000000001p-1022;
206         vdouble = 0x0.0000000000001P-1022;
207         vdouble = 0X0.0000000000001p+1022;
208         vdouble = 0X0.0000000000001P+1022;
209         vdouble = 0x.0P0;
210         vdouble = 0X0p+2;
211         vdouble = 0X0p+20F;
212         vdouble = 0X0p+2D;
213         vdouble = 0X0p+2d;
214         vdouble = 0x1.P-1;
215         vdouble = 0x.1___AFp1;
216         vstring = null;
217         vstring = "";
218         vstring = "\\";
219 
220         // assignments and operators
221         vint = 1 + 1;
222         vint = 1 - 1;
223         vint = 1 * 1;
224         vint = 1 / 1;
225         vint = 1 % 1;
226         vint = 1 & 1;
227         vint = 1 | 1;
228         vint = 1 ^ 1;
229         vint = ~1;
230         vboolean = 1 != 0;
231         vboolean = 1 == 0;
232         vboolean = 1 > 0;
233         vboolean = 1 >= 0;
234         vboolean = 1 < 0;
235         vboolean = 1 <= 0;
236         vboolean = true && true;
237         vboolean = true || true;
238         vboolean = true ? true : false;
239         vboolean = !true;
240         vboolean = f9 instanceof Object;
241         vint = 1 << 1;
242         vint = 1 >> 1;
243         vint = 1 >>> 1;
244         vint += 1;
245         vint -= 1;
246         vint *= 1;
247         vint /= 1;
248         vint %= 1;
249         vint &= 1;
250         vint |= 1;
251         vint ^= 1;
252         vint <<= 1;
253         vint >>= 1;
254         vint >>>= 1;
255         vint++;
256         vint--;
257         ++vint;
258         --vint;
259         String[] arrayinit = {};
260         String[] arrayinit2 = {""};
261         String[] arrayinit3 = {"", "",};
262 
263         // new
264         varray = new int[]{};
265         varray = new int[]{0};
266         varray = new int[]{0, 1};
267         varray = new int[5];
268         vlist = new ArrayList<String>();
269         vmap = new HashMap<String, String[]>();
270         Object anonymous = new InputRegressionJavaClass1() {};
271 
272         // statements
273         ;
274         this.f1 = 0;
275 
276         // labels
277         test_label1:
278 
279         // blocks
280         {}
281         if (true) ;
282         if (true) {}
283         if (true) {} else ;
284         if (true) {} else {}
285         if (b) { for (;;) ; }
286         if (b) { for (;;) {} }
287         for (int i = 0; i < 1; i++) {}
288         for (int i = 0, j = 0; i < 1; i++, j += 2) {}
289         for (int value: new int[]{}) ;
290         for (String s : new String[]{}) ;
291         for (final String s : new String[]{}) ;
292         if (b) { while (true) ; }
293         if (b) { while (true) {} }
294         do {} while (false);
295         synchronized (f9) {}
296 
297         switch (0) {
298             case 1:
299             case 0: break;
300             default: break;
301         }
302 
303         try {
304             if (b) { throw new IOException(); }
305             if (b) { throw new ArrayIndexOutOfBoundsException(); }
306             throw new Exception();
307         } catch (IOException | ArrayIndexOutOfBoundsException e) {
308         } catch (Exception e) {
309         } finally {}
310         try (BufferedReader br = new BufferedReader(new InputStreamReader(null, "utf-8"))) {}
311         try (BufferedReader br1 = new BufferedReader(new InputStreamReader(null, "utf-8"));
312                 BufferedReader br2 = new BufferedReader(new InputStreamReader(null, "utf-8"));) {}
313 
314         // access
315         test4 = InputRegressionJavaClass1.class;
316         test4 = List[].class;
317         test4 = boolean[].class;
318         varray[0] = 0;
319         for (String[] s : new String[][]{{}}) ;
320         for (Map.Entry<String, String[]> e : vmap.entrySet()) { }
321 
322         // others
323         for (;;) {break;}
324         test_label2:
325         for (;;) {break test_label2;}
326         if (b) { for (;;) {continue;} }
327         if (b) { test_label3: for (;;) {continue test_label3;} }
328         if (false) return;
329         if (false) throw new Exception();
330         assert(false);
331         assert true : "false";
332         f9 = (Object) f9;
333         f9.equals(((vstring = "")));
334         for (int i = 0; ((i) < (6+6)); i++) ;
335         if ((b & b)) {}
336 
337         // ast error handling
338         vint = vboolean ? (vint = 1) : (vint = 0);
339         varray[vint] = Integer.parseInt("0");
340     }
341 
342     public @interface innerAnnotation {}
343 }