On Tue, 4 Feb 2025 19:42:42 GMT, Jiangli Zhou <jian...@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! >> >> A custom launcher will typically link to libjvm or use dlopen/dlym to get to >> JNI_CreateJavaVM. A static build isn't really suitable for custom launchers >> (or anything that embeds a VM). >> >> So I think the changes to the test are okay if we really want to run this >> test with a static build. An alternative is to have the tests that use >> JNI_CreateJavaVM to not be selected. At some point I suspect we'll need to >> add a property to jtreg-ext/requires/VMProps.java for these builds anyway. > >> A static build isn't really suitable for custom launchers (or anything that >> embeds a VM). > > Just want to provide some relevant data point. We build custom launcher and > statically link with the libjvm (for hermetic case). If libjvm is statically > linked with the launcher, then there's actually no need to change the direct > calls to those JNI_ functions. The direct calls are not problematic on static > build. > >> An alternative is to have the tests that use JNI_CreateJavaVM to not be >> selected. > > The alternative also sounds reasonable to me. We could skip running on static > JDK if a test explicitly requires libjvm.so, libjava.so, etc at runtime, at > least initially. > >> At some point I suspect we'll need to add a property to >> jtreg-ext/requires/VMProps.java for these builds anyway. > > That's a good point. We can add a `vm.static.jdk` to help test selection. Thanks for clarifying @jianglizhou . Okay so the issue is only with the top-level invocation API functions: - JNI_GetDefaultJavaVMInitArgs - JNI_GetCreatedJavaVMs - JNI_CreateJavaVM and as noted launchers have the choice of either linking with libjvm.so or else using dynamic lookup. The former doesn't work with a static JDK (can we link with libjvm.a?). So in the context of fixing a couple of tests this is okay. ------------- PR Comment: https://git.openjdk.org/jdk/pull/23431#issuecomment-2635480736