Here's the test case:
import java.awt.*;
import java.awt.event.ActionListener;
import java.beans.EventHandler;
import javax.swing.*;
public class EventHandlerBug {
public static void main(String[] args) {
Object target = new EventHandlerBug();
JButton b = new JButton("hi");
ActionListener l = (ActionListener)
EventHandler.create(ActionListener.class, target, "foo",
"source.icon");
b.addActionListener(l);
b.doClick();
}
public void foo(Icon o) {
System.out.println("Icon: " + o);
}
}
When run you get the following NPE:
Exception in thread "main" java.lang.NullPointerException
at java.beans.EventHandler.invoke(EventHandler.java:354)
at $Proxy0.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1\863)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.ja\va:2183)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonMode\l.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:25\8)
at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
at javax.swing.AbstractButton.doClick(AbstractButton.java:282)
at EventHandlerBug.main(EventHandlerBug.java:14)
###@###.### 10/14/04 16:24 GMT