Let's say I have a super-class that defines the following abstract method
public abstract <T extends Interface> Class<T> getMainClass();
Now if I want to override it in some sub-class
public Class<Implementation> getMainClass(){
return Implementation.class;
}
I get a warning about type safety and unchecked conversion:
Type safety: The return type
Class<Implementation>
forgetMainClass()
from the typeSubFoo
needs unchecked conversion to conform toClass<Interface>
from the typeSuperFoo
Doesn't Class<Implementation>
fall under Class<T>
if <T extends Interface>
? Is there any way to properly get rid of the warning?