How can I obtain the type parameter of a generic interface from an implementing class?
问题 I have this interface: public interface EventHandler<T extends Event> { void handle(T event); } And this class implementing it: public class MyEventHandler implements EventHandler<MyEvent> { @Override public void handle(MyEvent event) { //do something } } In this clase, T parameter is MyEvent , that is a concrete implementation of Event . How can obtain this using reflection? 回答1: Resolve the type of T by the generic interface. E.g. public interface SomeInterface<T> { } public class