I have an interface, parametrized by <V>
and would like to pass the type parameter to a method like this:
public interface MyInterface<V extends BaseClass> {
<T> T myGenericMethod(Class<T> clazz);
default void run() {
...
String s = ((BaseClass) myGenericMethod(V)).getStringValue(); // <- V can not be resolved to a variable
...
}
}
As a workaround I use now method, returning the class, which I'd like to avoid:
Class<?> getType();
S myGenericMethod(Class clazz)`. – akarnokd Jun 16 '22 at 08:01` on the method definition)? Also, it is not really clear to me what you're trying to achieve here.– Mark Rotteveel Jun 16 '22 at 08:02