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 37 38 39 40 41 42 43 44 45 46 47 48 49
|
import org.checkerframework.checker.nullness.qual.*;
class UnannoPrimitives {
// :: error: (type.invalid.annotations.on.use)
@Nullable int f;
// TODO:: error: (type.invalid)
@NonNull int g;
void local() {
// test whether an arbitrary declaration annotation gets confused
@SuppressWarnings("tata")
int h = Integer.valueOf(5);
int i = Integer.valueOf(99) + 1900;
int j = 7 + 1900;
// :: error: (type.invalid.annotations.on.use)
@Nullable int f;
// TODO:: error: (type.invalid)
@NonNull int g;
}
static void testDate() {
@SuppressWarnings("deprecation") // for iCal4j
int year = new java.util.Date().getYear() + 1900;
String strDate = "/" + year;
}
// :: error: (type.invalid.annotations.on.use)
@Nullable byte[] d1 = {4};
byte @Nullable [] d1b = {4};
@SuppressWarnings("ha!")
byte[] d2 = {4};
// :: error: (type.invalid.annotations.on.use)
Object ar = new @Nullable byte[] {4};
// TODO:: error: (type.invalid)
Object ar2 = new @NonNull byte[] {42};
void testCasts(Integer i1) {
Object i2 = (int) i1;
// :: error: (type.invalid.annotations.on.use)
Object i3 = (@Nullable int) i1;
}
}
|