Closed jonashartwig closed 7 years ago
I had the tought. but it will not work if we have a folder like this: a.b/somelib than the "extension" would be b/somelib no idea if that is even valid in this case...
but it will not work if we have a folder like this: a.b/somelib than the "extension" would be b/somelib no idea if that is even valid in this case...
I cannot see how that could possible happen.
Took a brief look at the JVM sources and the native call to mapLibraryName()
essentially appends the JNI_LIB_SUFFIX
declared in jvm_md.h
, which is different for the various platforms.
Possible values are .dylib
, .dll
, and .so
.
So I think it's very safe to assume that something like this works:
final String systemLibraryName = System.mapLibraryName("");
final int dot = systemLibraryName.lastIndexOf('.');
final String extension = systemLibraryName.substring(dot+1);
And if it does not, we should fail with an exception anyway, which this code would.
Thanks, Jonas! Much appreciated.
I removed the unused header file import (I tested it in my use case). And i made NATIVE_LIBRARY_EXTENSION more dynamic. If you have time and approve the changes it would be nice if you make a 0.9.20 release so I can remove my fork from where i take my SNAPSHOT :)