<AWT Dev> RFR: 8182043: Access to Windows Large Icons [v4]

Alexey Ivanov aivanov at openjdk.java.net
Tue May 11 19:39:24 UTC 2021

On Tue, 11 May 2021 18:50:13 GMT, Alexander Zuev <kizune at openjdk.org> wrote:

>> src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java line 1192:
>>> 1190:      */
>>> 1191:     static Image getShell32Icon(int iconID, int size) {
>>> 1192:         long hIcon = getIconResource("shell32.dll", iconID, size, size);
>> It's outside the scope for this code review but still, should `getIconResource` free the loaded library? With each call, the library gets loaded but it's never freed and thus it's never unloaded even if it's not needed any more.
> I will create a separate bug to track this - i do not know if library loading gets cached on some level and what impact on performance will we have if we release it every call. But i will check it out separately.

Sure! I just wanted to bring it up. I could've submitted the bug myself… yet I decided to ask at first.
As far as I can see `JDK_LoadSystemLibrary` has no caching, it just loads the library. If any icons are accessed `shell32.dll` will already be loaded. Probably, we never fully release it from COM. So in this case, loading and freeing will just increase and decrease the counters. Even if it's never really unloaded, we should release the resources that's not needed any more.


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

More information about the awt-dev mailing list