catch UnsatisfiedLinkError on JNA load

This catches UnsatifiedLinkError when attempting to load the JNA Native
class, in cases where there are error loading the native libraries that JNA
needs to function.
This commit is contained in:
jaymode 2015-05-27 15:15:38 -04:00
parent 5acb40ca26
commit 6d96bfc98b
1 changed files with 6 additions and 4 deletions

View File

@ -34,12 +34,14 @@ class Natives {
static {
try {
// load one of the main JNA classes to see if the classes are available. this does not ensure that native
// libraries are available
// load one of the main JNA classes to see if the classes are available. this does not ensure that all native
// libraries are available, only the ones necessary by JNA to function
Class.forName("com.sun.jna.Native");
jnaAvailable = true;
} catch(ClassNotFoundException e) {
logger.warn("JNA not found. native methods will be disabled.");
} catch (ClassNotFoundException e) {
logger.warn("JNA not found. native methods will be disabled.", e);
} catch (UnsatisfiedLinkError e) {
logger.warn("unable to load JNA native support library, native methods will be disabled.", e);
}
}