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

[macos] NullPointerException getting bounds of GraphicsConfiguration

    Details

    • Subcomponent:
    • Resolved In Build:
      b19
    • CPU:
      x86
    • OS:
      os_x

      Backports

        Description

        ADDITIONAL SYSTEM INFORMATION :
        macOS Mojave 10.14.5 (MacBook Pro)

        openjdk version "12.0.2" 2019-07-16
        OpenJDK Runtime Environment AdoptOpenJDK (build 12.0.2+10)
        OpenJDK 64-Bit Server VM AdoptOpenJDK (build 12.0.2+10, mixed mode, sharing)

        A DESCRIPTION OF THE PROBLEM :
        The method java.awt.GraphicsConfiguration#getBounds can throw a NullPointerException when disconnecting displays.

        REGRESSION : Last worked in version 11.0.4

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the attached code on a MacBook Pro.

        While that is running:
        1) Plug in an external display to the laptop
        2) Close the laptop lid
        3) Unplug the external display
        -> Exception is thrown here
        4) Open the laptop lid

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        No exception is thrown
        ACTUAL -
        Exception in thread "main" java.lang.NullPointerException
        at java.desktop/sun.awt.CGraphicsDevice.getBounds(CGraphicsDevice.java:116)
        at java.desktop/sun.awt.CGraphicsConfig.getBounds(CGraphicsConfig.java:57)
        at Main.main(Main.java:10)

        ---------- BEGIN SOURCE ----------
        import java.awt.*;

        public class Main {

            public static void main(String[] args) {
                while (true) {
                    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
                    for (GraphicsDevice gd : ge.getScreenDevices()) {
                        GraphicsConfiguration gc = gd.getDefaultConfiguration();
                        gc.getBounds();
                    }
                }
            }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Catch the exception and ignore it.

        FREQUENCY : occasionally


          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  serb Sergey Bylokhov
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: