> For the second example, why the cast is not correct?
For any particular class (within a class loader context) there is
exactly one Class object. The type of the object will be
Class<ActualClass>, which is not assignment compatible with, say,
Class<Object>.
> Indeed, this is
> only way I can use EventListenerList.add(Class<T extends
> EventListener> c, T l) and remove(Class<T extends EventListener> c, T
> l) methods. Can you suggest a correct way to call these methods when
> the listener l is often an object of a subclass of EventListener?
Something along the lines of:
listeners.add(ActionListener.class, listener);
Using getClass on the listener is the last thing you want to do. You
want to keep together, say, all ActionListeners. getClass will never
return ActionListener.class, as it is an interface and so cannot be the
runtime class of any object.
Even if you did something odd by retrieving implemented interfaces,
event listeners often implement a number of listener interfaces for
different purposes.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/