Loads the JNA stub library. First tries jna.boot.library.path, then the system path, then from the jar file.
()
| 1008 | * jar file. |
| 1009 | */ |
| 1010 | private static void loadNativeDispatchLibrary() { |
| 1011 | if (!Boolean.getBoolean("jna.nounpack")) { |
| 1012 | try { |
| 1013 | removeTemporaryFiles(); |
| 1014 | } |
| 1015 | catch(IOException e) { |
| 1016 | LOG.log(Level.WARNING, "JNA Warning: IOException removing temporary files", e); |
| 1017 | } |
| 1018 | } |
| 1019 | |
| 1020 | String libName = System.getProperty("jna.boot.library.name", "jnidispatch"); |
| 1021 | String bootPath = System.getProperty("jna.boot.library.path"); |
| 1022 | if (bootPath != null) { |
| 1023 | // String.split not available in 1.4 |
| 1024 | StringTokenizer dirs = new StringTokenizer(bootPath, File.pathSeparator); |
| 1025 | while (dirs.hasMoreTokens()) { |
| 1026 | String dir = dirs.nextToken(); |
| 1027 | File file = new File(new File(dir), System.mapLibraryName(libName).replace(".dylib", ".jnilib")); |
| 1028 | String path = file.getAbsolutePath(); |
| 1029 | LOG.log(DEBUG_JNA_LOAD_LEVEL, "Looking in {0}", path); |
| 1030 | if (file.exists()) { |
| 1031 | try { |
| 1032 | LOG.log(DEBUG_JNA_LOAD_LEVEL, "Trying {0}", path); |
| 1033 | System.setProperty("jnidispatch.path", path); |
| 1034 | System.load(path); |
| 1035 | jnidispatchPath = path; |
| 1036 | LOG.log(DEBUG_JNA_LOAD_LEVEL, "Found jnidispatch at {0}", path); |
| 1037 | return; |
| 1038 | } catch (UnsatisfiedLinkError ex) { |
| 1039 | // Not a problem if already loaded in anoteher class loader |
| 1040 | // Unfortunately we can't distinguish the difference... |
| 1041 | //System.out.println("File found at " + file + " but not loadable: " + ex.getMessage()); |
| 1042 | } |
| 1043 | } |
| 1044 | if (Platform.isMac()) { |
| 1045 | String orig, ext; |
| 1046 | if (path.endsWith("dylib")) { |
| 1047 | orig = "dylib"; |
| 1048 | ext = "jnilib"; |
| 1049 | } else { |
| 1050 | orig = "jnilib"; |
| 1051 | ext = "dylib"; |
| 1052 | } |
| 1053 | path = path.substring(0, path.lastIndexOf(orig)) + ext; |
| 1054 | LOG.log(DEBUG_JNA_LOAD_LEVEL, "Looking in {0}", path); |
| 1055 | if (new File(path).exists()) { |
| 1056 | try { |
| 1057 | LOG.log(DEBUG_JNA_LOAD_LEVEL, "Trying {0}", path); |
| 1058 | System.setProperty("jnidispatch.path", path); |
| 1059 | System.load(path); |
| 1060 | jnidispatchPath = path; |
| 1061 | LOG.log(DEBUG_JNA_LOAD_LEVEL, "Found jnidispatch at {0}", path); |
| 1062 | return; |
| 1063 | } catch (UnsatisfiedLinkError ex) { |
| 1064 | LOG.log(Level.WARNING, "File found at " + path + " but not loadable: " + ex.getMessage(), ex); |
| 1065 | } |
| 1066 | } |
| 1067 | } |
no test coverage detected