JDK-8263157 : [macos]: java.library.path is being set incorrectly
  • Type: Bug
  • Component: tools
  • Sub-Component: jpackage
  • Affected Version: 15,16,17
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2021-03-04
  • Updated: 2021-07-22
  • Resolved: 2021-04-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17 b18Fixed
Related Reports
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
macOS Catalina 10.15.7

openjdk version "15.0.2" 2021-01-19
OpenJDK Runtime Environment (build 15.0.2+7-27)
OpenJDK 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)

WARNING: Using incubator modules: jdk.incubator.jpackage
15.0.2

A DESCRIPTION OF THE PROBLEM :
Previously on OS X java.library.path would include paths internal to the application. 
some.app/Contents/MacOS and some.app/Contents/app
MacOS could probably be eliminated as 'app' is the jpackage supported way to include user files.
However, these paths no longer appear included and instead external paths are.


REGRESSION : Last worked in version 14

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Start an application with needed dylib's in the input directory to go to the app directory.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The native library will successfully load based on the java.library.path setting.
ACTUAL -
Exception in thread "main" java.lang.UnsatisfiedLinkError: no hp in java.library.path: /opt/ooRexx/lib/ooRexx:/Users/mjh/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
	at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source)
	at java.base/java.lang.Runtime.loadLibrary0(Unknown Source)
	at java.base/java.lang.System.loadLibrary(Unknown Source)
	at us.hall.osx.LogOut.<clinit>(LogOut.java:9)
	at us.hall.hp.common.LoaderLaunchStub.main(LoaderLaunchStub.java:59)

The load fails because java.library.path no longer seems to include the internal 'app' directory.

CUSTOMER SUBMITTED WORKAROUND :
Setting the java.library.path as a startup option like...
-Djava.library.path=$APPDIR

FREQUENCY : always



Comments
Reply from the submitter ========================= It appears to work correctly at this version. Override removed from jpackage invocation --java-options '-Xmx1024m -XX:+UseG1GC -XX:MaxGCPauseMillis=50 -Djava.security.policy=$APPDIR/all.policy -Dapple.laf.useScreenMenuBar=true -Dcom.apple.mrj.application.apple.menu.about.name=HalfPipe -Dapple.awt.application.name=HalfPipe -Dconsole=pane' \ From the application��� versions System.in:3:java.version=17-ea System.in:5:java.version.date=2021-09-14 System.in:14:java.class.version=61.0 System.in:15:java.vm.specification.version=17 System.in:18:java.vm.version=17-ea+21-1866 System.in:21:java.runtime.version=17-ea+21-1866 System.in:24:java.specification.version=17 set java.library.path java.library.path=/Users/mjh/HalfPipe/HalfPipe_jpkg/outputdir/HalfPipe.app/Contents/app:/Users/mjh/HalfPipe/HalfPipe_jpkg/outputdir/HalfPipe.app/Contents/MacOS:/Users/mjh/wekafiles/native The app directory is included. Given that jpackage doesn���t use it the MacOS directory could still probably be removed. I���m not seeing how compatibility would be a concern. But yes, a fix.
11-05-2021

Requested the submitter to see if the bug is fixed in the latest build at https://jdk.java.net/17/ b21.
11-05-2021

Changeset: 55d56495 Author: Alexander Matveev <almatvee@openjdk.org> Date: 2021-04-13 21:36:55 +0000 URL: https://git.openjdk.java.net/jdk/commit/55d56495
13-04-2021

Regression from JDK-8242302.
10-04-2021

Reply received from the submitter =============================== public class Test { public static void main(String[] args) { System.out.println(System.getProperty("java.library.path")); } } javac Test.java jar -cvf test.jar Test.class mkdir input mv test.jar input/test./jar jpackage --type app-image --input input --main-jar test.jar --main-class Test Test.app/Contents/MacOS/Test /opt/ooRexx/lib/ooRexx:/Users/mjh/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. That was with jdk-15.0.2 Falling back to 14 took a little effort but when done. /usr/libexec/java_home -v 14 --exec jpackage --type app-image --input input --main-jar test.jar --main-class Test Test.app/Contents/MacOS/Test /Users/mjh/Documents/TestApp/Test.app/Contents/app:/Users/mjh/Documents/TestApp/Test.app/Contents/MacOS Note the paths difference.
08-03-2021

Requested for a simple reproducer from the submitter
05-03-2021