On Thu, 18 Jan 2024 17:26:30 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>> Replaced asserts with NullPointerException calls because outside of testing >> that would be more informative - i do not think many people running their >> applications with assertions in system libraries enabled; >> Added a code that will analyze the result of the getIcon and will fall back >> to the default icon for the file type retrieved from the ShellFolder; >> Added a test case made by Aleksei Ivanov. > > src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java line > 1208: > >> 1206: } else { >> 1207: return new MultiResolutionIconImage(size, >> multiResolutionIcon); >> 1208: } > > Can we return `null` immediately if an icon that we're about to put into > `multiResolutionIcon` is `null`? > > That is change the line 1198(1195) > https://github.com/openjdk/jdk/blob/1640fbb1d4b1bcc5196b0055858403a4bd524359/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java#L1198 > > to > > > if (newIcon == null) { > return null; > } > multiResolutionIcon.put(s, newIcon); > > > I assume if `newIcon == null` then `hIcon` is also `null`, in which case we > can move this condition to the line 1195(1192) > > https://github.com/openjdk/jdk/blob/1640fbb1d4b1bcc5196b0055858403a4bd524359/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java#L1195 > > before calling `makeIcon`. Ok, i will move it to the line 1198 because i can not guarantee that we do not need to dispose hIcon if we can not make icon out of it so i would rather avoid potential resource leak. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/17475#discussion_r1457897661