I have a bit of a problem understanding Java's type erasure when it comes to bounded types. Consider this:
class Event {} // From the API
class FooEvent extends Event {}
abstract class Foo<EventType extends Event> {
public abstract <E extends EventType> void onEventCaught(E event);
}
class Bar extends Foo<FooEvent> {
@Override
public void onEventCaught(FooEvent event) {
}
}
Apparently this compiles without problems. The question that I ask myself is, for which parameter-types is Bar#onEventCaught()
declared, here (as in, what does reflection think)?
Is it onEventCaught(FooEvent event)
or maybe onEventCaught(Event event)
?