jnr / jnr-ffi

Java Abstracted Foreign Function Layer
Other
1.26k stars 157 forks source link

[feature request] #309

Open chenjia123 opened 2 years ago

chenjia123 commented 2 years ago

Why not support search for different locations by platform? Just like JNA.

Snipaste_2022-07-10_21-10-26

Now I implement similar functionality with the following code:

Platform nativePlatform = Platform.getNativePlatform();
Platform.OS os = nativePlatform.getOS();
Platform.CPU cpu = nativePlatform.getCPU();
String searchPath = String.format(basePath + "/src/main/resources/%s-%s", os, cpu);
XXX obj =  LibraryLoader.create(XXX.class).search(searchPath).load("some_so");

But use JNA:

XXX obj = Native.load("some_so", XXX.class);
jowilkes commented 2 years ago

I don't get it - Why would this functionality go into the library, when the library search path is a standard part of the runtime environment?