After a whole lot of searching, I came across this little snippet in the JLS, section 15.8.2 Class Literals:
If p is the name of a primitive type, let B be the type of an expression of type p after boxing conversion (§5.1.7). Then the type of p.class is Class<B>.
The spec doesn't explain why this is so, instead of Class<?> for example. I have also been unable to find any evidence that this is related to either generics or autoboxing.
Integer is a first-class object whereas int is a primitive type, and most methods of Class such as isInstance, isAssignableFrom and cast which operate on Objects are invalid in the context of int.class. Consequently, I do not see any reason why the type of int.class is Class<Integer>.
int.classis:public static final Class<Integer> TYPE = (Class<Integer>) Class.getPrimitiveClass("int");Since the type parameter doesn't truly matter and it's boxed, it's passable.IntegerusingInteger.classbut there is no way to do this withint.class.intat all via reflection, it's a primitive. The decision is quite simple: the primitives are boxed, so anywhere you can pass an int, an Integer would do (or vice verse). There is one exception though: simple class parameters are totally different, reflection likegetMethod("xxx", Integer.class)won't work forxxx(int x).int.classis neither a superclass nor a subclass ofInteger.class,Integer.class.isAssignableFrom(int.class) == falseandint.class.cast(0)throws aClassCastException. I don't see anything that can be done usingint.classthat relates toClass<Integer>.<...>just make code unreadable