aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/InputRegressionJavaClass1.java
blob: 04684c6463d8441c032938b7cc343869d16e599e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
package com.puppycrawl.tools.checkstyle.grammars;

import static java.lang.String.valueOf;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.xml.*;

public class InputRegressionJavaClass1 {
    //comments

    // single line
    /* multi on single line */
    /* multi
     line */
    /** javadoc */
    // tab ->	<-

    // fields
    // modifiers
    public int f1;
    private int f2;
    protected int f3;
    int f4;
    static int f5;
    final int f6;
    volatile int f7;
    transient int f8;
    Object f9;

    // constructors
    static {}
    public InputRegressionJavaClass1() {f6 = 0;}
    public InputRegressionJavaClass1(int i) {this.f6 = i;}
    public InputRegressionJavaClass1(float f) {this((int)f);}
    InputRegressionJavaClass1(double a) throws Exception {f6 = 0;}

    // methods
    // modifiers
    native void m1();
    void m2() {}
    synchronized void m4() {}
    strictfp void m5() {}    
    
    // returns
    public int[] m6() {return null;}
    public int m7() [] {return null;}

    // parameters
    public void m10(String p1) {}
    public void m11(final String p1) {}
    public void m12(String[] p1) {}
    public void m13(String[][] p1) {}
    public void m14(String p1, String p2) {}
    public void m15(String... p1) {}
    public void m16(String[]... p1) {}
    public void m17(int p1, String[]... p2) {}

    // throws
    public void m18() throws Exception {}
    public void m19() throws IOException, Exception {}

    // types
    public <T_$> T_$ m20() {return null;}
    public <$_T> $_T m21() {return null;}
    public <T extends Enum<T>> void m22() {}
    public <T> void m23() {};
    public <T extends RuntimeException & java.io.Serializable> void m24() {}
    
    // annotations
    @SuppressWarnings({})
    public void m50() {}
    @SuppressWarnings({"1"})
    public void m51() {}
    @SuppressWarnings({"1","2"})
    public void m52() {}
    @SuppressWarnings(value={"1"})
    public void m53() {}
    @SuppressWarnings(value={"1",})
    public void m54() {}
    @SuppressWarnings(value={"1","2"})
    public void m55() {}
    @InputRegressionJavaAnnotation1(m1="1", m2="2")
    public void m56() {}
    @ComplexAnnotation({
            @InputRegressionJavaAnnotation1(m1 = "1"), @InputRegressionJavaAnnotation1(m1 = "1")
    })
    public void m57() {}
    public void m58(@Deprecated String s) {}
    public void m59(final @Deprecated List l) {}

    // extra
    {}
    ;

    // instructions
    public void instructions() throws Exception {
        // used to let inputs compile
        boolean b = Math.random() > 0;

        // variables and types
        byte vbyte;
        boolean vboolean;
        char vchar;
        short vshort;
        int vint;
        long vlong;
        float vfloat;
        double vdouble;
        int[] varray;
        int varray2[];
        boolean test1 = true;

        // types
        String vstring;
        List<String> vlist;
        Map<String, String[]> vmap;
        int[] test2 = {};
        List<char[]> test3;
        Class<?> test4;
        List<? extends InputRegressionJavaClass1> test5;
        List<? extends List<Object>> test6;
        List<? extends List<List<Object>>> test7;
        List<? extends int[]> test8;
        List<? super InputRegressionJavaClass1> test9;

        // literals
        vboolean = true;
        vboolean = false;
        vchar = ' ';
        vchar = '"';
        vchar = '\0';
        vchar = '\'';
        vchar = '\n';
        vchar = '\r';
        vchar = '\t';
        vchar = '\b';
        vchar = '\f';
        vchar = '\"';
        vchar = '\'';
        vchar = '\\';
        vchar = '\00';
        vchar = '\013';
        vchar = '\4';
        vchar = '\40';
        vchar = '\u0000';
        vchar = '\u1234';
        vchar = '\u005C\u005C';
        vchar = '\u005c\u005c';
        vchar = '\uu005C\uuuuu005C';
        vchar = '\u005cn';
        vchar = '\u005cr';
        vchar = '\u005ct';
        vchar = '\u005cb';
        vchar = '\u005cf';
        vchar = '\u005c"';
        vchar = '\u005c'';
        vchar = '\u005c\';
        vint = 0;
        vint = -1;
        vint = +1;
        vint = 100_000;
        vint = 0x00;
        vint = 0x12345678;
        vint = 0X9;
        vint = 0x1234_5678;
        vint = 0b101;
        vint = 0B101;
        vint = 0b1;
        vint = 0b1_0;
        vint = 012345670;
        vint = 01234_5670;
        vlong = 0L;
        vlong = 1L;
        vlong = 0b1L;
        vlong = 1234567890l;
        vlong = 1234567890L;
        vlong = 0x0l;
        vlong = 0xABCDEFl;
        vlong = 0XABCDEFL;
        vfloat = 0f;
        vfloat = 0F;
        vfloat = 1.1f;
        vfloat = 1.10_1F;
        vfloat = 0_1.1_1F;
        vfloat = 1e0f;
        vfloat = 1e0F;
        vfloat = 1.0e0F;
        vfloat = 0x2__3_34.4___AFP00_00f;
        vdouble = 10.;
        vdouble = .1;
        vdouble = .1__1_1;
        vdouble = 0.0;
        vdouble = 1000.0;
        vdouble = .1d;
        vdouble = 1.D;
        vdouble = 0_1.0d;
        vdouble = 0_1.0D;
        vdouble = 4e23;
        vdouble = 4E23;
        vdouble = 4E2_3;
        vdouble = 0x0.0000000000001p-1022;
        vdouble = 0x0.0000000000001P-1022;
        vdouble = 0X0.0000000000001p+1022;
        vdouble = 0X0.0000000000001P+1022;
        vdouble = 0x.0P0;
        vdouble = 0X0p+2;
        vdouble = 0X0p+20F;
        vdouble = 0X0p+2D;
        vdouble = 0X0p+2d;
        vdouble = 0x1.P-1;
        vdouble = 0x.1___AFp1;
        vstring = null;
        vstring = "";
        vstring = "\\";
        
        // assignments and operators
        vint = 1 + 1;
        vint = 1 - 1;
        vint = 1 * 1;
        vint = 1 / 1;
        vint = 1 % 1;
        vint = 1 & 1;
        vint = 1 | 1;
        vint = 1 ^ 1;
        vint = ~1;
        vboolean = 1 != 0;
        vboolean = 1 == 0;
        vboolean = 1 > 0;
        vboolean = 1 >= 0;
        vboolean = 1 < 0;
        vboolean = 1 <= 0;
        vboolean = true && true;
        vboolean = true || true;
        vboolean = true ? true : false;
        vboolean = !true;
        vboolean = f9 instanceof Object;
        vint = 1 << 1;
        vint = 1 >> 1;
        vint = 1 >>> 1;
        vint += 1;
        vint -= 1;
        vint *= 1;
        vint /= 1;
        vint %= 1;
        vint &= 1;
        vint |= 1;
        vint ^= 1;
        vint <<= 1;
        vint >>= 1;
        vint >>>= 1;
        vint++;
        vint--;
        ++vint;
        --vint;
        String[] arrayinit = {};
        String[] arrayinit2 = {""};
        String[] arrayinit3 = {"", "",};
        
        // new
        varray = new int[]{};
        varray = new int[]{0};
        varray = new int[]{0, 1};
        varray = new int[5];
        vlist = new ArrayList<String>();
        vmap = new HashMap<String, String[]>();
        Object anonymous = new InputRegressionJavaClass1() {};

        // stataments
        ;
        this.f1 = 0;
        
        // labels
        test_label1:

        // blocks
        {}
        if (true) ;
        if (true) {}
        if (true) {} else ;
        if (true) {} else {}
        if (b) { for (;;) ; }
        if (b) { for (;;) {} }
        for (int i = 0; i < 1; i++) {}
        for (int i = 0, j = 0; i < 1; i++, j += 2) {}
        for (int value: new int[]{}) ;
        for (String s : new String[]{}) ;
        for (final String s : new String[]{}) ;
        if (b) { while (true) ; }
        if (b) { while (true) {} }
        do {} while (false);
        synchronized (f9) {}
        
        switch (0) {
            case 1:
            case 0: break;
            default: break;
        }

        try {
            if (b) { throw new IOException(); }
            if (b) { throw new ArrayIndexOutOfBoundsException(); }
            throw new Exception();
        } catch (IOException | ArrayIndexOutOfBoundsException e) {
        } catch (Exception e) {
        } finally {}
        try (BufferedReader br = new BufferedReader(new FileReader(""))) {}
        try (BufferedReader br1 = new BufferedReader(new FileReader(""));
                BufferedReader br2 = new BufferedReader(new FileReader(""));) {}
        
        // access
        test4 = InputRegressionJavaClass1.class;
        test4 = List[].class;
        test4 = boolean[].class;
        varray[0] = 0;
        for (String[] s : new String[][]{{}}) ;
        for (Map.Entry<String, String[]> e : vmap.entrySet()) { }

        // others
        for (;;) {break;}
        test_label2:
        for (;;) {break test_label2;}
        if (b) { for (;;) {continue;} }
        if (b) { test_label3: for (;;) {continue test_label3;} }
        if (false) return;
        if (false) throw new Exception();
        assert(false);
        assert true : "false";
        f9 = (Object) f9;
        f9.equals(((vstring = "")));
        for (int i = 0; ((i) < (6+6)); i++) ;
        if ((b & b)) {}
        
        // ast error handling
        vint = vboolean ? (vint = 1) : (vint = 0);
        varray[vint] = Integer.parseInt("0");
    }

    public @interface innerAnnotation {}
}