You cannot tell Java to always return Child.class regardless of T There may be other classes extending from the parent that are not Child . Also, since you are not using T anywhere, your code does not make much sense. Two possible solutions:
public Class<? extends Parent> getAClass() { return Child.class; }
or maybe
public <T extends Parent> Class<T> getAClass(Class<T> clazz){ return clazz; }
The second example compiles, but it probably makes sense if T was declared at the class level.
In addition, I renamed your method to avoid a name clash with the existing getClass() method.
source share