According to the spec, type annotations on class literals are prohibited (http://baloo.ru.oracle.com/jenkins/job/jck8a-lang/lastSuccessfulBuild/artifact/build/out/htmlout/jls-15.html#jls-15.8.2-110)
The following code, however, is accepted by the compiler:
class Test {
public static void test() {
Class c = int @Simple [] .class; //compiles
}
}
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER }) @interface Simple {}
The same code is not compiled if we use Integer instead of int:
class Test {
public static void test() {
Class c = int @Simple [] .class; // javac error here
}
}
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER }) @interface Simple {}
The situation is similar for other primitive types.
Seems like a regression, because in b27 both cases were rejected by the compiler, and in b34 the situation is as described.