I have an abstract class:
public abstract class RootProcessor<T> {
Class<T> clazz;
}
I need to fill ClassT clazz;
with the children of RootProcessor
- every child has its own T
I found only one solution, but it needs compiler argument -Xlint:unchecked
public RootProcessor(){
this.clazz = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];
}
Is this the best solution? Can we do the same without -Xlint:unchecked
?