RFR: 8348106: Catch C++ exception in Java_sun_awt_windows_WTaskbarPeer_setOverlayIcon [v4]

Alexey Ivanov aivanov at openjdk.org
Mon Feb 17 13:06:11 UTC 2025


On Sun, 16 Feb 2025 03:25:50 GMT, Rajat Mahajan <rmahajan at openjdk.org> wrote:

>> **Issue:**
>> The JNI method `Java_sun_awt_windows_WTaskbarPeer_setOverlayIcon `calls `CreateIconFromRaster `that can throw a C++ exception.
>> 
>> The C++ exception must be caught and must not be allowed to escape the JNI method. The call to `CreateIconFromRaster `has to wrapped into a try-catch block.
>> 
>> **Solution:**
>> 
>> Added exception handling to make sure any exception from `CreateIconFromRaster `is handled properly.
>> 
>> Testing done.
>
> Rajat Mahajan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   CATCH_BAD_ALLOC

The suggestion was to use the macros: [`TRY`](https://github.com/openjdk/jdk/blob/ab66c82ce9fdb5ee3fd7690f42b8ad4d78bf5e40/src/java.desktop/windows/native/libawt/windows/alloc.h#L131-L134) and [`CATCH_BAD_ALLOC`](https://github.com/openjdk/jdk/blob/ab66c82ce9fdb5ee3fd7690f42b8ad4d78bf5e40/src/java.desktop/windows/native/libawt/windows/alloc.h#L154-L160).

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

Changes requested by aivanov (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/23470#pullrequestreview-2621002791


More information about the client-libs-dev mailing list