RFR: 8346377: Properly support static builds for Windows [v2]
Magnus Ihse Bursie
ihse at openjdk.org
Fri Dec 20 13:11:22 UTC 2024
On Fri, 20 Dec 2024 13:05:53 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:
>> src/java.desktop/windows/native/libawt/windows/awt_Mlib.cpp line 53:
>>
>>> 51: */
>>> 52: if (JVM_IsStaticallyLinked()) {
>>> 53: hDLL = ::GetModuleHandle(NULL);
>>
>> So this returns a handle to the process instead ?
>> I suppose this exists for apps that want the process, not for apps that can't get a handle to a DLL.
>> I am not sure if this is always sufficiently equivalent to work for whatever the app needs it for .. I hope this doesn't create downstream problems that we need to fix.
>
> `hDLL` is a static variable scoped inside `hDLL`, so it easy to see all places it is used in. They are all about doing `GetProcAddress` for the exported functions in `mlib_image`. This is following a pattern from how we've handled static/dynamic duality elsewhere in the JDK. What we're really after in the `hDLL` variable is getting a handle to something that can look up e.g. "j2d_mlib_ImageCreate". For a dynamic build, that is a DLL, but for a static build, it is the executable.
In passing it can be noted that a corresponding will are going to be needed on Linux as well. This has not been done, since the linux static build only supports headless-only builds as of yet.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22795#discussion_r1893919610
More information about the build-dev
mailing list