Suppose I have a Java class hierarchy defined as follow:
interface Bar<T> {}
class Foo<A,B> implements Bar<B> {}
How can I programmatically assess (using reflection) that the type parameter of Bar in Foo is the second of foo's parameters and not the first (B instead of A)?
I've tried using TypeVariable#getName()
in order to compare the names, but when I apply getGenericInterfaces()
to Foo<A,B>
I get Bar<T>
and not Bar<B>
Aucun commentaire:
Enregistrer un commentaire