Jtreg tests with JNI native code on static JDK

Jiangli Zhou jianglizhou at google.com
Mon Feb 3 19:42:10 UTC 2025


Thanks for the thoughts, Jorn!

On Mon, Feb 3, 2025 at 6:07 AM Jorn Vernee <jorn.vernee at oracle.com> wrote:

> Could you give some examples of the assumptions you're talking about here?
>

One example is test/hotspot/jtreg/runtime/jni/atExit/TestAtExit.java.
When building libatExt, it explicitly links with libjvm.so (e.g. on
Linux), which becomes a recorded dependency of libatExit.so:

https://github.com/openjdk/jdk/blob/618c5eb27b4c719afd577b690e6bcb21a45fcb0d/make/test/JtregNativeHotspot.gmk#L883C40-L883C49
```
BUILD_HOTSPOT_JTREG_LIBRARIES_JDK_LIBS_libatExit := java.base:libjvm
```

```
$ ldd ./build/linux-x86_64-server-release/support/test/hotspot/jtreg/native/lib/libatExit.so
linux-vdso.so.1 (0x00007fb80017c000)
libjvm.so => (snip)
...
/lib64/ld-linux-x86-64.so.2 (0x00007fb80017e000)
```

Runtime linker and loader would resolve and load the dependency
`libjvm.so` when loading `libatExit.so`. As static-jdk does not
provide `libjvm.so`, it would fail when running the test using the
static-jdk. I filed https://bugs.openjdk.org/browse/JDK-8349178.

The good thing is so far testing only has found just a few such cases
in Tier1 tests.

Best regards,
Jiangli


More information about the jdk-dev mailing list