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

When DISPLAY is bad, InternalError thrown, not AWTError

XMLWordPrintable

    • x86
    • linux

        ---%<---
        import java.awt.AWTError;
        import java.awt.Toolkit;
        public class TestAWTError {
            public static void main(String[] args) {
                try {
                    System.out.println(Toolkit.getDefaultToolkit());
                } catch (AWTError x) {
                    System.err.println("Expected: " + x);
                }
            }
        }
        ---%<---

        $ uname -a
        Linux jglick-laptop 2.6.27-11-generic #1 SMP Thu Jan 29 19:24:39 UTC 2009 i686 GNU/Linux

        $ java -showversion TestAWTError
        java version "1.6.0_11"
        Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
        Java HotSpot(TM) Server VM (build 11.0-b16, mixed mode)

        sun.awt.X11.XToolkit@bb7465

        $ (unset DISPLAY; java TestAWTError)
        sun.awt.HeadlessToolkit@1e4457d

        $ DISPLAY=:77 java TestAWTError
        Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':77' as the value of the DISPLAY variable.
        at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
        at sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52)
        at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
        at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:89)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at java.awt.Toolkit$2.run(Toolkit.java:834)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:826)
        at TestAWTError.main(TestAWTError.java:6)

        The Javadoc descriptions for AWTError vs. InternalError, and the fact that only AWTError is mentioned in getDefaultToolkit Javadoc, would lead me to believe that AWTError would be thrown in case the JVM could not initialize AWT due to an unusable X11 display reference. (Or at least that HeadlessToolkit would be used.)

              mcherkas Mikhail Cherkasov (Inactive)
              jglick Jesse Glick (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: