brettwooldridge / NuProcess

Low-overhead, non-blocking I/O, external Process implementation for Java
Apache License 2.0
710 stars 84 forks source link

M1 ARM support for JVM #129

Closed abuggin closed 2 years ago

abuggin commented 3 years ago

Could not initialize class com.zaxxer.nuprocess.osx.OsxProcess

on 16.0.1+9 Zulu: 16.30.19 for ARM 64-bit v8 arch on M1 macbook

I noticed because I was unable to run scala metals plugin from vs-code. Feel free to close if unrelevant.

bturner commented 3 years ago

You should be able to "fix" this yourself by overriding the JNA version in your POM to be 5.8.0 (or newer) rather than the 5.6.0 NuProcess currently depends on. NuProcess itself doesn't need code changes to support M1; it's JNA that causes the issue. JNA support for M1 is in 5.8.0.

doctorpangloss commented 2 years ago

I'm seeing errors in:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/xxx/Library/Caches/JNA/temp/jna17154497639452279821.tmp: dlopen(/Users/xxx/Library/Caches/JNA/temp/jna17154497639452279821.tmp, 0x0001): tried: '/Users/xxx/Library/Caches/JNA/temp/jna17154497639452279821.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64e')), '/usr/lib/jna17154497639452279821.tmp' (no such file)
        at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
        at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2383)
        at java.base/java.lang.Runtime.load0(Runtime.java:746)
        at java.base/java.lang.System.load(System.java:1857)
        at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1018)
        at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:988)
        at com.sun.jna.Native.<clinit>(Native.java:195)
        at com.sun.jna.NativeLibrary.<clinit>(NativeLibrary.java:87)
        at com.zaxxer.nuprocess.internal.LibC.<clinit>(LibC.java:38)
bturner commented 2 years ago

Yes, that implies you need a newer JNA. But, again, it doesn't require changes to NuProcess to get that; you just need to declare your own JNA dependency in your project a higher version. NuProcess doesn't need to be compiled against JNA 5.10 to use 5.10 at runtime.