File: Loop.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,840 kB
  • sloc: java: 145,910; xml: 839; sh: 518; makefile: 401; perl: 26
file content (36 lines) | stat: -rw-r--r-- 1,061 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
import java.util.Iterator;
import java.util.Set;
import org.checkerframework.common.value.qual.ArrayLen;
import org.checkerframework.common.value.qual.BottomVal;
import org.checkerframework.common.value.qual.IntVal;

public class Loop {
    void test1(final double @ArrayLen(20) [] f2) {
        int x;
        for (int g = 0; g < f2.length; g++) {
            x = g;
        }
        // :: error: (assignment.type.incompatible)
        double @BottomVal [] test = f2;
        // :: error: (assignment.type.incompatible)
        @BottomVal int q = f2.length;
    }

    void test2(final @IntVal(20) int param) {
        int x;
        for (int g = 0; g < param; g++) {
            x = g;
        }
        // :: error: (assignment.type.incompatible)
        @BottomVal int q = param;
    }

    private void test3(Set<String> set) {
        String[] array = new String[set.size()];
        int i = 0;
        for (Iterator<String> iter = set.iterator(); iter.hasNext(); ) {
            String key = iter.next();
            array[i++] = key;
        }
    }
}