Mam dostepny literal interface'u i chciałbym utworzona klasę zrzutować na ten interface.
Action act = new Action(ActionListener.class);
// Wypisuje 'interface java.awt.event.ActionListener'
System.out.println(act.getInterface().toString());
// Wypisuje ActionListener
if(act.getInterface() == ActionListener.class) {
System.out.println("ActionListener");
}
Jak teraz jakiś obiekt zrzutować na ten interface.?
EventListener el = k.get();
// Takie dziala
ActionListener al = (ActionListener)el;
// To nie ;/
ActionListener al2 = act.getInterface().cast(el);