I have a problem when using generic types. IDE show me following error:
Cannot select from a type variable
I think here problem with type erasure, but I think here exist some workaround...
My code:
class MyFactory {
public Object getByClass(Class<?> clazz) {
.....
}
}
class<T> MyClass {
private Object myObj = MyFactory.getByClass(T.class); // HERE ERROR, `Cannot select from a type variable`
...
}
How to solve this problem?
T.classis supposed to refer to.TypeofTmay not even be aClass.