I have an abstract test class that has two type parameters. I need to make an instance of one of the types at some point, so I defined an abstract method to get the required class.
I doc = getInputDocumentClass().newInstance();
How can I implement the abstract method Class<T1<T2>> getInputDocumentClass() in a concrete subclasses?
To return the class literal for T1 is not enough:
@Override
public Class<T1<T2>> getInputDocumentClass() {
return T1.class;
}
cannot convert from Class<T1> to Class<T1<T2>>
There are no parameterized class literals due to type erasure.
So how can I satisfy the compiler in this case?
1 Answer