On Linux (Debian 13/trixie x86_64), the configure option --with-jni-libpath to change the default JNI path does not seem to be taken into account.
For example, this build:
sh configure --with-jni-libpath=/usr/lib/jni:/usr/lib/x86_64-linux-gnu/jni
Then returns the default:
./build/linux-x86_64-server-release/jdk/bin/jshell << EOF
System.getProperty("java.library.path")
EOF
jshell> $1 ==> "<absolute path to working copy>/build/linux-x86_64-server-release/jdk/lib/default:<absolute path to working copy>/build/linux-x86_64-server-release/jdk/lib:/usr/lib64:/usr/lib"
Tests with actual JNI libraries do not work unless -Djava.library.path is explicitly set (here with the SWT Hello World [1]):
# sudo apt install libswt-gtk-4-java
./build/linux-x86_64-server-release/jdk/bin/java -cp /usr/share/java/swt4.jar Snippet1.java
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
Can't load swt-gtk-4962r3
Can't load swt-gtk
Can't load swt
Can't load /usr/lib/jni/libswt-gtk.so
Can't load /usr/lib/jni/libswt.so
Can't load /home/mbaudier/.swt/lib/linux/x86_64/libswt-gtk-4962r3.so
Can't load /home/mbaudier/.swt/lib/linux/x86_64/libswt-gtk.so
Can't load /home/mbaudier/.swt/lib/linux/x86_64/libswt.so
./build/linux-x86_64-server-release/jdk/bin/java -Djava.library.path=/usr/lib/jni:/usr/lib/x86_64-linux-gnu/jni -cp /usr/share/java/swt4.jar Snippet1.java
# show SWT windows
The default Debian OpenJDK (openjdk-21-jdk) does not need -Djava.library.path since it has been built with this configuration option [2].
Does OpenJ9 use another mechanism to override the default JNI path at build time?
[1] https://github.com/eclipse-platform/eclipse.platform.swt/blob/master/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet1.java
[2] https://salsa.debian.org/openjdk-team/openjdk/-/blob/openjdk-21/debian/rules?ref_type=heads#L412
On Linux (Debian 13/trixie x86_64), the configure option --with-jni-libpath to change the default JNI path does not seem to be taken into account.
For example, this build:
Then returns the default:
Tests with actual JNI libraries do not work unless
-Djava.library.pathis explicitly set (here with the SWT Hello World [1]):The default Debian OpenJDK (openjdk-21-jdk) does not need
-Djava.library.pathsince it has been built with this configuration option [2].Does OpenJ9 use another mechanism to override the default JNI path at build time?
[1] https://github.com/eclipse-platform/eclipse.platform.swt/blob/master/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet1.java
[2] https://salsa.debian.org/openjdk-team/openjdk/-/blob/openjdk-21/debian/rules?ref_type=heads#L412