I need to describe a certain abstract type as a class, which itself will be a generic of this abstract type (for convenience of serialization and deserialization):
public class TypeSpec<T> { private final Class<T> type; private final List<TypeSpec<?>> parameters; ... } List<TypeSpec<?>> parameters = Arrays.asList(new TypeSpec<>(B.class), new TypeSpec<>(C.class); TypeSpec<A<B, C>> specification = new TypeSpec<>(A.class, parameters); The problem is that Java is justifiably protected and does not like such things: I cannot pass Class<A<B, C>> A.class Class<A<B, C>> as the first parameter, because it does not exist (there is only A.class type Class<A> ), otherwise limiting the type of nowhere to take. How to properly resolve such situations?
TypeTokenin gson ? - zRrr