On Mon, 20 Jan 2025 21:32:17 GMT, Magnus Ihse Bursie <i...@openjdk.org> wrote:

>> 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.

Yep. A static function could be optimised out… inlined. However, if the address 
of the function is taken, the function should remain as a stand-alone callable 
function. Adding `static` shouldn't remove the function, it just ensures the 
function name isn't visible to other .obj files.

I'm not 100% sure, yet I think it should work correctly even when 
`GetAwtModuleHandle` is declared `static`.

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

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

Reply via email to