Closed rubin55 closed 5 years ago
After a bit of digging, it sounds like the order is:
.dylib
suffix.jnilib
suffix.Likely something we need to change in ClassLoader loadLibraryWithPath
or maybe loadLibraryWithClassLoader
@fengxue-IS Can you take a look at this?
Looking into this
We are using port library api j9sl_open_shared_library
for loading libraries, the file extension is defined in OMR https://github.com/eclipse/omr/blob/cfeaf3a68032d9cf352d53c07abce500b4fa98cf/port/unix/omrsl.c#L76-L80
I'll update the api to check for .jnilib
suffix if it failed to locate library using .dylib
@DanHeidinga JVM also uses this suffix during the preloadLibrary
method,
https://github.com/eclipse/openj9/blob/3a46f0e858546387c6740de2f89cba607bf590d1/runtime/j9vm/jvm.c#L2395-L2397
Is there a need to update this as well? (My understanding is that preloadLibrary
is only for internal libraries which doesn't use the .jnilib
suffix)
Is there a need to update this as well?
No, we don't need to update the internal preloadLibrary calls
@fengxue-IS Can we control this behaviour from OpenJ9 rather than OMR? My assumption is we'd attempt to do the load as a .dylib
and only if it fails, fall back to .jnilib
.
Maybe by hacking the code in https://github.com/eclipse/openj9/blob/3ce824471411143746d7f749c5391a4c4e5a5c3c/runtime/vm/vmbootlib.c#L250-L252
@DanHeidinga the platform dependent file name (ie. lib<name>.dylib
) is filled in the port API automatically.
If we want to have the code in OpenJ9, we would have to copy some of that functionality from OMR to expend the lib name before passing into omrsl_open_shared_library()
If this is the preferred solution, I'll close the PR in OMR and move the changes into OpenJ9
It seems odd to add to OMR a very java-specific sharedlibrary suffix like .jnilib
.
It's reasonable for OpenJ9 to either pass in the library name or maybe to add a new API to OMR to register alternative sharedlibrary suffixes.
Will talk to OMR reviewer whether adding new API for alternative suffixes is feasible.
On second though, this would be more straight forward to implement in OpenJ9 by removing the decorate flag and pre-expending the full name of the library.
When running some applications with OpenJ9 that depend on some Java Native Interface stuff on macOS, OpenJ9 seems to not be able to load those dependencies when they're called
<something>.jnilib
. It will load them when one renames or links to the files with a<something>.dylib
name.Here's some error output from Tanuki wrapper as used within Anypoint Studio (an Eclipse based IDE):
When I enter the above mentioned directory (
[..]/lib/boot
) I don't see a file namedlibwrapper-macosx-universal-64.dylib
, but I do see a file namedlibwrapper-macosx-universal-64.jnilib
. Note the extension. Renaming or linking to the file makes the wrapper work. This problem does not occur on Hotspot.