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

Possible NPE with EventHandler

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 6
    • Fix Version/s: 6
    • Component/s: client-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b11
    • CPU:
      x86
    • OS:
      linux_redhat_9.0

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: