File: DontCrash.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 (28 lines) | stat: -rw-r--r-- 1,052 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
// This code is illegal (javac issues an error), but nonetheless the
// org.checkerframework.checker shouldn't crash.  (Maybe they shouldn't run at all if javac
// issues any errors?)
// @skip-test

import java.util.HashMap;
import java.util.Map;
import org.checkerframework.checker.interning.qual.Interned;

public class DontCrash {

    // from VarInfoAux
    static class VIA {
        // :: non-static variable this cannot be referenced from a static context
        // :: inner classes cannot have static declarations
        // :: non-static variable this cannot be referenced from a static context
        // :: inner classes cannot have static declarations
        private static VIA theDefault = new VIA();
        private Map<@Interned String, @Interned String> map;

        void testMap() {
            Map<@Interned String, @Interned String> mymap;
            mymap = theDefault.map;
            mymap = new HashMap<@Interned String, @Interned String>(theDefault.map);
            mymap = new HashMap<>(theDefault.map);
        }
    }
}