RFR: 8282862: AwtWindow::SetIconData leaks old icon handles if an exception is detected [v6]

Alexey Ivanov aivanov at openjdk.org
Mon Jan 20 15:47:37 UTC 2025


On Fri, 17 Jan 2025 23:37:01 GMT, Rajat Mahajan <rmahajan at openjdk.org> wrote:

>> src/java.desktop/windows/native/libawt/windows/awt_Window.cpp line 2115:
>> 
>>> 2113:     HICON hNewIcon = NULL;
>>> 2114:     HICON hNewIconSm = NULL;
>>> 2115: 
>> 
>> I presume we know for sure there's no exception pending when we enter ?
>> Looking at the only caller, it seems probable.
>
> Are you suggesting we add a JNU_CHECK_EXCEPTION the beginning of the function? , as I don't think we know for sure there is an exception pending or not at this point.

> I presume we know for sure there's no exception pending when we enter ?
> Looking at the only caller, it seems probable.

There can't be a pending exception when `AwtWindow::SetIconData` starts.

The chain starts with JNI method [`Java_sun_awt_windows_WWindowPeer_setIconImagesData`](https://github.com/openjdk/jdk/blob/0fbf10a9cf51d01d82cd43cf0edfaeee83313a9c/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp#L3133) which calls [`AwtWindow::_SetIconImagesData`](https://github.com/openjdk/jdk/blob/0fbf10a9cf51d01d82cd43cf0edfaeee83313a9c/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp#L3149) wrapped in `SyncCall`.

No Java code is called before execution gets into `SetIconData` where `CreateIconFromRaster` is called.

> …I don't think we know for sure there is an exception pending or not at this point.

I'm sure there's no pending exception on the entry to `AwtWindow::SetIconData`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22932#discussion_r1922587897


More information about the client-libs-dev mailing list