Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6179222

Possible NPE with EventHandler

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • client-libs
    • None
    • b11
    • x86
    • linux_redhat_9.0

      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

            svioletsunw Scott Violet (Inactive)
            svioletsunw Scott Violet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: