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

The crash in XRobotPeer when the custom GraphicsDevice is used

XMLWordPrintable

    • b16
    • generic
    • linux

        The code below crashes on Unix:

        import java.awt.GraphicsConfiguration;
        import java.awt.GraphicsDevice;
        import java.awt.Robot;

        public class CrashRobot {

             public static void main(final String[] args) throws Exception {
                 final GraphicsDevice gd = new GraphicsDevice() {
                     @Override
                     public int getType() {
                         return TYPE_RASTER_SCREEN;
                     }

                     @Override
                     public String getIDstring() {
                         return "Custom screen device";
                     }

                     @Override
                     public GraphicsConfiguration[] getConfigurations() {
                         return new GraphicsConfiguration[0];
                     }

                     @Override
                     public GraphicsConfiguration getDefaultConfiguration() {
                         return null;
                     }
                 };

                 final Robot r = new Robot(gd);
                 r.getPixelColor(0, 0);
             }
        }

        On macOS the java.lang.ClassCastException is occured.

              serb Sergey Bylokhov
              serb Sergey Bylokhov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: