File: IdentityArrayList.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,274 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.Arrays;
import org.checkerframework.checker.fenum.qual.FenumTop;

/*
 * This test case violates an assertion in the compiler.
 * It does not depend on the Fenum Checker, it breaks for any checker.
 */
public class IdentityArrayList {
    // The type of the third argument to Arrays.copyOf should be:
    // Class<? extends T @FenumTop []>
    // But the annotated JDK does not have annotations for the Fenum Checker.
    @SuppressWarnings("argument.type.incompatible")
    public <T> T[] toArray(T[] a) {
        // Warnings only with -Alint=cast:strict.
        // TODO:: warning: (cast.unsafe)
        // :: warning: [unchecked] unchecked cast
        return (T[]) Arrays.copyOf(null, 0, a.getClass());
    }

    public <T> T[] toArray2(T[] a) {
        wc(null, 0, new java.util.LinkedList<T[]>());
        // TODO:: warning: (cast.unsafe)
        // :: warning: [unchecked] unchecked cast
        return (T[]) myCopyOf(null, 0, a.getClass());
    }

    public static <T, U> T[] myCopyOf(
            U[] original, int newLength, Class<? extends T @FenumTop []> newType) {
        return null;
    }

    public static <T, U> T[] wc(
            U[] original, int newLength, java.util.List<? extends T @FenumTop []> arr) {
        return null;
    }
}