<AWT Dev>  Review request for 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
anthony.petrov at oracle.com
Mon Sep 23 06:45:49 PDT 2013
On 09/23/13 17:38, sergey malenkov wrote:
>> I suggest to check both bounds for the default screen index. Something
>> like the following should do: max(0, min(index, screens.length - 1)).
> Seems we should fix other environments too.
>> Also, I assume that getScreenDevices() can't return null or an empty
>> array, can it? For added safety, we might want to check this too, and
>> return null in this case.
> The getScreenDevices method can't return null, but it could be an empty
> array. There are many places, where the getDefaultScreenDevice method is
> used. Our code does not expect the null value. We could throw
> HeadlessException instead. What do you think?
That indeed seems logical. Moreover, the HeadlessException doesn't have
a specification yet (see 8016313). However, I think that AWT doesn't
consider itself headless even if the devices array is empty. Headless is
a special mode, after all. I'd go with returning null for now - other
code will catch NPEs, but that's OK. Later we may decide whether
consider this case headless or not.
>> best regards,
>> On 09/23/13 16:47, sergey malenkov wrote:
>>> Could you please review the following fix:
More information about the awt-dev