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

Two methods of GraphicsEnvironment doesn't throw expected HE on Windows, 7b74

XMLWordPrintable

    • generic
    • windows

      The following code below doesn't throw HeadlessException if executed with -Djava.awt.headless=true

      Platform: Windows
      JDK 7 b74 - FAILS
      JDK 7 b73 - PASSES

      though methods of class java.awt.GraphicsEnvironment

          public abstract GraphicsDevice getDefaultScreenDevice()
          public abstract GraphicsDevice[] getScreenDevices()

      mention

           * @exception HeadlessException if isHeadless() returns true

      -----------------------------------------------------------------------------------
      import java.awt.*;

      public class TestGetDefScreenDevice {
          public static void main(String[] args) {
              GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
              try {
                  // the following methods must throw HeadlessException in headless mode
                  ge.getDefaultScreenDevice();
                  ge.getScreenDevices();
                  System.out.println("Failed. HeadlessException not thrown");
              } catch (HeadlessException he) {
                  System.out.println("Passed. HeadlessException thrown as expected");
              }
          }
      }
      -----------------------------------------------------------------------------------

            Unassigned Unassigned
            dbessono Dmitry Bessonov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: