JDK-8238936 : The crash in XRobotPeer when the custom GraphicsDevice is used
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 11,15
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: generic
  • Submitted: 2020-02-11
  • Updated: 2022-12-20
  • Resolved: 2020-03-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 15
11.0.19Fixed 15 b16Fixed
Related Reports
Relates :  
Description
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.
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk11u-dev/pull/1601 Date: 2022-12-18 02:34:33 +0000
19-12-2022

Fix Request (11u) - Justification: The fix for the crash. - Risk Analysis: Low, the change initially was pushed to jdk15. - Testing: The fix verified by the new test, and the jdk_desktop tests are green - PR: https://github.com/openjdk/jdk11u-dev/pull/1601
19-12-2022

URL: https://hg.openjdk.java.net/jdk/jdk/rev/53efe5255d14 User: psadhukhan Date: 2020-03-22 11:49:29 +0000
22-03-2020

URL: https://hg.openjdk.java.net/jdk/client/rev/53efe5255d14 User: serb Date: 2020-03-03 06:27:25 +0000
03-03-2020

The root cause is how we trying to access the multiscreen information in the native code.
12-02-2020