In my program I have an abstract base class with a generic parameter. In this class I have to get the Class object of the generic parameter used in a subclass. Currently I do it like this:
public abstract class BaseItem<T>
    public BaseItem(int id, Class<T> childGenricClass) {
        //...
    }
}
public class MainItem extends BaseItem<String> {
    public MainItem(int id) {
        super(id, String.class);
    }
}
Do I really have to pass the class via the constructor to the parent class or is there a way in Java to dynamically get this from the parent class?
 
    