The problem you have here is that the specification for generics has evolved over time .: | The latest version of Sun / Oracle Java compiles this code correctly, but its IDE, which does not implement it, now compiles. (Unfortunately, Eclipse uses its own compiler and is not always exactly the same as the Sun / Oracle compiler)
I am sure that older versions of the compiler will result in an error for this line of code.
It used to be that if the type was not generic, all generics were disabled, even if that didn't make sense. In the case of this method.
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
Older compilers suggest that this was not a general method, since the constructor is not general. However, the new compiler identifies this method on its own and it does not matter if the class is a typical type.
source share