There’s some Apple library policy that’s preventing the library from loading (code signature in (/Users/<username>/Library/Containers/com.pkg.MyApp/Data/Library/Caches/JNA/temp/jna5601997128572859092.tmp) not valid for use in process using Library Validation: library load disallowed by system policy).
A potential cause is that MacOS does not allow code created at runtime (which is typical malware behaviour), and that extracting a library at runtime looks like that code was created because it’s not visible outside the jar file in which it came.
I prepared for this scenario by pre-extracting the library and bundling it as part of the installer. I also had JNA load the pre-extracted library instead of letting it extract and load it.
I’d love to hear about your success. We don’t currently bundle JNA in our MacOS build, but eventually we will, and any data points will help us decide how to proceed.
Regards,
Jo
--
You received this message because you are subscribed to the Google Groups "Java Native Access" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
jna-users+...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jna-users/e81b8ffc-b32f-4c87-8264-179d6bfa7899n%40googlegroups.com.
Sensitivity: C2 Internal
The content of this e-mail is intended only for the
confidential use of the person addressed.
If you are not the intended
recipient, please notify the sender and delete this e-mail immediately.
Thank
you.
Library Loading
When JNA classes are loaded, the native shared library (jnidispatch) is loaded as well. An attempt is made to load it from the any paths defined in jna.boot.library.path (if defined), then the system library path using System.loadLibrary(java.lang.String), unless jna.nosys=true. If not found, the appropriate library will be extracted from the class path (into a temporary directory if found within a jar file) and loaded from there, unless jna.noclasspath=true. If your system has additional security constraints regarding execution or load of files (SELinux, for example), you should probably install the native library in an accessible location and configure your system accordingly, rather than relying on JNA to extract the library from its own jar file.
To avoid the automatic unpacking (in situations where you want to force a failure if the JNA native library is not properly installed on the system), set the system property jna.nounpack=true.
While this class and its corresponding native library are loaded, the system property jna.loaded will be set. The property will be cleared when native support has been unloaded (i.e. the Native class and its underlying native support has been GC'd).
NOTE: all native functions are provided within this class to ensure that all other JNA-provided classes and objects are GC'd and/or finalized/disposed before this class is disposed and/or removed from memory (most notably Memory and any other class which by default frees its resources in a finalizer).
To view this discussion on the web visit https://groups.google.com/d/msgid/jna-users/ZRAP278MB0737C4C5177D0FABBDA5B2EDB9E49%40ZRAP278MB0737.CHEP278.PROD.OUTLOOK.COM.
Prints this:
MyApp.app/Contents/app
And I see the .jar and other libs there if I expand the .app.
But if I boot the app i get this error:
/Volumes/MyApp/MyApp.app/Contents/app
Nov 05, 2024 8:07:06 PM com.sun.jna.Native loadNativeDispatchLibrary
INFO: Looking in /Users/danielzanchi/java.library.path/libjnidispatch.jnilib
Nov 05, 2024 8:07:06 PM com.sun.jna.Native loadNativeDispatchLibrary
INFO: Looking in /Users/danielzanchi/java.library.path/libjnidispatch.dylib
Nov 05, 2024 8:07:06 PM com.sun.jna.Native extractFromResourcePath
INFO: Looking in classpath from jdk.internal.loader.ClassLoaders$AppClassLoader@4b85612c for /com/sun/jna/darwin-aarch64/libjnidispatch.jnilib
Nov 05, 2024 8:07:06 PM com.sun.jna.Native extractFromResourcePath
INFO: Found library resource at jar:file:/Volumes/MyApp/MyApp.app/Contents/app/jna-5.10.0.jar!/com/sun/jna/darwin-aarch64/libjnidispatch.jnilib
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not find JNA native support
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1039)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:1015)
at com.sun.jna.Native.<clinit>(Native.java:221)
at com.sm.myapp.SH3DBridge.SH3DBridge.init(Unknown Source)
at com.a.myapp.analytics.AnalyticsObject$2.run(Unknown Source)
at com.a.myapp.analytics.AnalyticsObject.init(Unknown Source)
at com.a.myapp.analytics.AnalyticsManager.init(Unknown Source)
at com.a.myapp.myapp.init(Unknown Source)
at com.a.myapp.myapp.main(Unknown Source)
Failed to launch JVM
Thanks in advance
To view this discussion visit https://groups.google.com/d/msgid/jna-users/b6bdf474-b477-4964-bd77-618a9d2b4832n%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jna-users+unsubscribe@googlegroups.com.