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

EventQueue.invokeLater works incorrectly

    XMLWordPrintable

    Details

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

      Description



      Name: dsR10051 Date: 01/24/2001


      The method
      java.awt.EventQueue.invokeLater(Runnable runnable)
      may not call run method of runnable if this method was
      called before with null parameter.

      Here is a minimized test:

      import java.awt.*;
      import java.awt.event.*;

      public class Test02 {

          public static void main (String[] args) {
              for (int i = 0; i < 100; i++) {
                  System.out.println(i);
                  System.out.flush();
                  EventQueue.invokeLater(null);
                  MoreRunnable runnable = new MoreRunnable();
                  EventQueue.invokeLater(runnable);
                  try {
                      runnable.WAIT();
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          }
      }

      class MoreRunnable implements Runnable {
          public boolean run_done = false;

          public synchronized void WAIT() throws InterruptedException {
              while (!run_done) {
              System.out.println("MoreRunnable.WAIT");
              System.out.flush();
                  wait();
              }
          }

          public synchronized void NOTIFY() {
              run_done = true;
              System.out.println("MoreRunnable.NOTIFY");
              System.out.flush();
              notifyAll();
          }

          public void run() {
              NOTIFY();
          }
      }

      --- Output ---
      %java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b48)
      Java HotSpot(TM) Client VM (build 1.4beta-B48, mixed mode)
      %java Test02
      0
      java.lang.NullPointerException
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:435)
              at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:140)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:126)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:121)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
      MoreRunnable.WAIT
      MoreRunnable.NOTIFY
      1
      MoreRunnable.WAIT
      java.lang.NullPointerException
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:435)
              at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:140)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:126)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:121)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
      ^C%

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ehawkessunw Eric Hawkes (Inactive)
              Reporter:
              sdasunw Sda Sda (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: