On Fri, 8 Oct 2021 10:23:13 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

> In JDK 9 the native code for the robot class was reworked to get an access to 
> the HiDPI quality screenshots. So we allocate the data storage for the HiDPI 
> quality and then request the best quality from the macOS.
> 
> It works fine if the user request the screenshot of some area, since we 
> properly scale this area. Unfortunately it does not work well if the user 
> request only one pixel, in this case we allocate the array of one element and 
> does not multiply the size by the scale, so if the system scale is 2 then the 
> macOS returns the 2x2 pixels, which does not fit properly to the array of one 
> element. This can be checked by the Xcheck:jni option which produce fatal 
> error in this case.
> 
> Solution is to allocate the storage of the proper size 1 * scale * 1 * scale

Looking at what happens in native it seems like it should be possible to add a 
check that the
Java array has enough capacity to satisfy what the call to retrieve pixels 
expects. 
I think it would be reasonable to throw InternalError if it does not !

-------------

PR: https://git.openjdk.java.net/jdk/pull/5864

Reply via email to