RFR: 8349284: Make libExplicitAttach work on static JDK [v2]

Alan Bateman alanb at openjdk.org
Sat Feb 8 09:32:10 UTC 2025


On Fri, 7 Feb 2025 20:10:02 GMT, Jiangli Zhou <jiangli at openjdk.org> wrote:

>> This is similar to https://github.com/openjdk/jdk/pull/23431 change. It removes libjvm.so as a recorded dependency for libExplicitAttach.so by not explicitly link libExplicitAttach.so with libjvm.so at build time. To do that, it also changes libExplicitAttach.c to dynamically lookup the JNI_GetCreatedJavaVMs symbol then invokes the function using the obtained address. The change makes the test to work on both regular 'jdk' image and the 'static-jdk' image.
>> 
>> There are discussions in https://github.com/openjdk/jdk/pull/23431 comment thread among @dholmes-ora, @AlanBateman and myself. Based on my understanding, we are converging on the approach to fix just these few tests, and both @dholmes-ora and @AlanBateman are okay with that. So I'm sending out this PR for libExplicitAttach's fix as well.
>
> Jiangli Zhou has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Move JNI_GetCreatedJavaVMs lookup into JNI_OnLoad, to address AlanBateman's suggestion.

test/jdk/java/lang/Thread/jni/AttachCurrentThread/libExplicitAttach.c line 57:

> 55:         return JNI_ERR;
> 56:     }
> 57:     return JNI_VERSION_1_8;

Is the JavaVM param passed to JNI_OnLoad usable in static builds? If so then this just needs to be saved, no need to use GetCreatedJavaVMs, right?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23500#discussion_r1947551019


More information about the build-dev mailing list