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

api/java_awt/Toolkit/index.html#GetAWTEventListeners Fails with:empty array returned unexpectedly

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b48
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      In headless mode listeners that were added using method

       java.awt.Toolkit.addAWTEventListener(AWTEventListener listener, long eventMask)

      are not returned by method

       java.awt.Toolkit.getAWTEventListeners(long eventMask)

      Please see the following code sample (should be executed with VM arg "-Djava.awt.headless=true" )

      ----------------
      import java.awt.event.AWTEventListener;
      import java.awt.*;

      public class Temp {

          public static void main(String[] args) {

              Toolkit toolkit = Toolkit.getDefaultToolkit();

              toolkit.addAWTEventListener(new AWTEventListener() {
                  public void eventDispatched(AWTEvent event) { }
              }, AWTEvent.CONTAINER_EVENT_MASK);

              if ( toolkit.getAWTEventListeners(AWTEvent.CONTAINER_EVENT_MASK).length == 0 ) {
                  throw new RuntimeException("An empty array returned unexpectedly");
              }
          }
      }
      ----------------

      The problem was cought by JCK QA on JDK7 b32

      Due to this problem the following JCK test fails in Headless mode, but passes with display.
      api/java_awt/Toolkit/index.html#GetAWTEventListeners[GetAWTEventListeners_4]: Failed. An empty array returned unexpectedly

        Attachments

          Activity

            People

            Assignee:
            dav Andrei Dmitriev (Inactive)
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: