File: ObjectClone.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 (27 lines) | stat: -rw-r--r-- 963 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
// Test case for issue 146: https://github.com/kelloggm/checker-framework/issues/146

import java.util.Arrays;
import org.checkerframework.checker.index.qual.*;

class ObjectClone {

    void test(int[] a, int @SameLen("#1") [] b) {
        int @SameLen("a") [] c = b.clone();
        int @SameLen({"a", "d"}) [] d = b.clone();
        int @SameLen({"a", "e"}) [] e = b;
        int @SameLen("f") [] f = b;
    }

    public static void main(String[] args) {
        String @SameLen("args") [] args2 = args;
        String @SameLen({"args", "args_sorted"}) [] args_sorted = args.clone();
        Arrays.sort(args_sorted);
        String @SameLen({"args", "args_sorted"}) [] args_sorted2 = args_sorted.clone();
        if (args_sorted.length == 1) {
            @IndexFor("args_sorted") int i = 0;
            @IndexFor("args") int j = 0;
            String @SameLen({"args", "args_sorted"}) [] k = args;
            System.out.println(args[0]);
        }
    }
}