Since there is no such thing as ArrayList<ChildModel>.class , there will not be an elegant way to solve this problem. You can pass you the raw type of your constructor, as Yasin mentioned, for example:
Service<ChildModel, ArrayList<ChildModel>> s1 = new Service<>(ChildModel.class, (Class) ArrayList.class)
The difference with your call is that here we are using the raw type of Class , while your example uses the type of Class<ArrayList> (so this is not an error).
Another option is to get the type from the actual instance:
Class<ArrayList<ChildModel>> fromObj = (Class<ArrayList<ChildModel>>) new ArrayList<ChildModel>(0).getClass();
This is more verbose, but I would prefer that over the raw type (in both cases you will get compiler warnings)
source share