class Super<T> {}
class Child<A, B> extends Super<B> {}
class Code {
public void method(Child<String, Integer> child) {}
}
I can use reflection to get the parameter type:
ParameterizedType ptype = (ParameterizedType) Code.class.getMethod("method").getGenericParameterTypes()[0]
But how can I get the generic superclass of ptype (meaning, not only Super.class
, but also the type parameter Integer
)
My use case is that I want to use reflection to determine if one of the arguments of a method is a Collection of MyClass objects (I don't have an actual argument instance to check)