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

JMenu.removeAll() throws unexpected NullPointerException

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5.1

      Description



      Name: aaC67449 Date: 12/22/98


      JMenu.removeAll() throws unexpected NullPointerException, when popupMenu is not initialized.

      See example.

      One line should be added to the code to fix this bug

      JMenu.java:713:
          public void removeAll() {
              if(popupMenu!=null) { // <--- test popupMenu is initialized
      popupMenu.removeAll();
              }
      clearListenerRegistry();
          }


      --------------- Example---------------------------
      import javax.swing.*;

      public class Test{
          public static void main(String argv[]) {
              JMenu c = new JMenu(); // Create JMenu object
              c.removeAll();

          }
      }

      ----------------output------------------
      Exception in thread "main" java.lang.NullPointerException
              at javax.swing.JMenu.removeAll(Compiled Code)
              at Test.main(Compiled Code)


      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gsaab Georges Saab
                Reporter:
                aalievsunw Artem Aliev (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: