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;
}
}
|