RFR: 8346388: Cannot use DllMain in libawt for static builds [v4]

Magnus Ihse Bursie ihse at openjdk.org
Mon Jan 20 21:34:38 UTC 2025


On Mon, 20 Jan 2025 16:49:33 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Magnus Ihse Bursie has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains five commits:
>> 
>>  - Merge branch 'master' into dll-main-in-libawt
>>  - Simplify patch
>>  - Merge branch 'master' into dll-main-in-libawt
>>  - Merge branch 'master' into dll-main-in-libawt
>>  - 8346388: Cannot use DllMain in libawt for static builds
>
> src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp line 108:
> 
>> 106:  * of a dynamic library build, or the .EXE in case of a static build.
>> 107:  */
>> 108: HMODULE GetAwtModuleHandle() {
> 
> Should it be `static`? The function `GetAwtModuleHandle` isn't used outside of this translation unit and can be marked `static` to explicitly hide from other translation units unless it stops working.

Actually, this function needs to be **not** static for it to work -- it uses it's own address to look up the handle that contains it -- which will be awt.dll when running a normal, dynamic build, and the entire java.exe when running a static build.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22790#discussion_r1922859162


More information about the client-libs-dev mailing list