RFR: 8349178: runtime/jni/atExit/TestAtExit.java should be supported on static JDK
Jiangli Zhou
jiangli at openjdk.org
Tue Feb 4 16:53:10 UTC 2025
On Tue, 4 Feb 2025 10:42:50 GMT, David Holmes <dholmes at openjdk.org> wrote:
> @jianglizhou I will be brutally honest and say that I do not like this at all. Does this mean all JNI using tests/applications have to becoded differently to be used with a static JDK? I find it somewhat ironic that to work with a _static_ JDK we have to rewrite the test to perform a _dynamic_ lookup!
@dholmes-ora Thanks for the forthright response. JNI functions are already dynamically called. E.g. in the same test here:
res = (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL);
We don't need to change those at all to work on static-jdk. The existing design of JNI functions can work on both dynamic JDK and static JDK.
The calls fixed by this PR are the very few exceptions that do not follow the design principle. I do think we should fix them by following the right patterns/conventions. Note `LoadJavaVM` in JDK code (https://github.com/openjdk/jdk/blob/b985347c2383a7a637ffa9a4a8687f7f7cde1369/src/java.base/unix/native/libjli/java_md.c#L524C1-L524C11) calls these functions 'properly', see
https://github.com/openjdk/jdk/blob/b985347c2383a7a637ffa9a4a8687f7f7cde1369/src/java.base/unix/native/libjli/java_md.c#L548.
So far I've only found this test in hotspot tier1 and libExplicitAttach (AttachTest_id0) in JDK tier1 with the issue.
@dholmes-ora If we don't go this change, do you have any other suggestion? One other possible alternative that I can think is using weak symbols, however I think that's no better.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23431#issuecomment-2634531490
More information about the build-dev
mailing list