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

EventQueue.pop() throws NullPointerException instead of EmptyStackException

XMLWordPrintable

    • sparc
    • solaris_2.5



      Name: mgC56079 Date: 04/24/98



      Javadoc says:

          /**
           * Stop dispatching events using this EventQueue instance.
           * Any pending events are transferred to the previous
           * EventQueue for processing by it. If called from the
           * initial EventQueue for this AWTContext, an
           * EmptyStackException is thrown.
           */
          protected synchronized void pop() throws EmptyStackException
              synchronized (newEventQueue) {
                  newEventQueue.queue = queue; // may be null
                  newEventQueue.prev = this;
                  next = newEventQueue;
              }
          }


      ---- Here is the test ----
      import java.util.EmptyStackException;
      import java.awt.*;

      public class EventQueueTest {
        public static void main(String[] args) {
          NewEventQueue q=new NewEventQueue();
          try {
            q.pop();
          }
          catch (EmptyStackException e) {
            System.out.println("passed");
          }
          System.out.println("EmptyStackException expected");
        }

      }

      class NewEventQueue extends EventQueue {
        public void pop() throws EmptyStackException {
          super.pop();
        }

      }
      ---- Sample run ----
      % java EventQueueTest
      java.lang.NullPointerException
      at java.awt.EventQueue.pop(EventQueue.java:198)
      at NewEventQueue.pop(EventQueueTest.java:20)
      at EventQueueTest.main(EventQueueTest.java:8)


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

            dmendenhsunw David Mendenhall (Inactive)
            mgorshen Mikhail Gorshenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: