RFR: JDK-8344907 : NullPointerException in Win32ShellFolder2.getSystemIcon when "icon" is null
Alexey Ivanov
aivanov at openjdk.org
Tue Dec 17 14:52:38 UTC 2024
On Tue, 17 Dec 2024 14:19:41 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java line 1220:
>>
>>> 1218: Image icon = makeIcon(hIcon);
>>> 1219: if (icon != null && size != icon.getWidth(null)) {
>>> 1220: icon = new MultiResolutionIconImage(size, icon);
>>
>> Although `icon != null` check is not strictly required here due to `hIcon != 0` check, added it as sanity check and to be consistent with other locations in Win32ShellFolder2.java where makeIcon() is called (which is followed by a null check for the returned icon).
>
> I'd leave it out here. As @azuev-java [notes above](https://github.com/openjdk/jdk/pull/22776/files#r1887863199), the likely problem is `hIcon == 0` rather than `makeIcon` returns `null`.
> > Although `icon != null` check is not strictly required here due to `hIcon != 0` check, added it as sanity check and to be consistent with other locations in Win32ShellFolder2.java where makeIcon() is called (which is followed by a null check for the returned icon).
>
> I'd leave it out here. As @azuev-java [notes above](https://github.com/openjdk/jdk/pull/22776/files#r1887863199), the likely problem is `hIcon == 0` rather than `makeIcon` returns `null`.
Now that I've thought about it more, you're right `icon != null` is also needed… if the icon bits can't be extracted which can also occur if *GDI resources are exhausted*.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22776#discussion_r1888645356
More information about the client-libs-dev
mailing list