I have an interface:
interface A<V, E extends Base<V>>
Then I have a concrete implementation:
class C<V, E extends Base<V>> implements A<V, E>
for C
, I have a constructor:
C(Class<? extends E> eClass)
Normally, we could just pass in EImpl.class
, but in this call, the eClass would be something like Base<String>
.
so:
new C<String, Base<String>> c = new C<>(???);
Is that possible? How would you pass in the class type for a generic since it just gets erased at runtime.
If I pass in Base.class
, that would of course work, but then I need to type cast it since its a raw type and its unchecked which is ugly.
1