File: TwoStaticInitBlocks.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,104 kB
  • sloc: java: 145,916; xml: 839; sh: 518; makefile: 404; perl: 26
file content (45 lines) | stat: -rw-r--r-- 791 bytes parent folder | download | duplicates (3)
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
import java.util.regex.*;

// this is a test-case for initialization that covers multiple initializer blocks, field
// initializers and a few other things
class TwoStaticInitBlocks {

    String f2;
    String f1 = (f2 = "");

    {
        t = "";
        f1.toString();
        f2.toString();
    }

    final String ws_regexp;
    String t;
    String s;

    {
        ws_regexp = "hello";
        t.toString();
        // :: error: (dereference.of.nullable)
        s.toString();
    }
}

class TwoStaticInitBlocks2 {
    static String f2;
    static String f1 = (f2 = "");

    static {
        t = "";
        f1.toString();
        f2.toString();
    }

    static final String ws_regexp;
    static String t;

    static {
        ws_regexp = "hello";
        t.toString();
    }
}