()
| 30 | } |
| 31 | |
| 32 | public static synchronized void load() { |
| 33 | if (_loaded) return; |
| 34 | |
| 35 | String version = readResource("/jwm.version"); |
| 36 | File tempDir = new File(System.getProperty("java.io.tmpdir"), "jwm_" + (version == null ? "" + System.nanoTime() : version)); |
| 37 | String arch = "aarch64".equals(System.getProperty("os.arch")) ? "arm64" : "x64"; |
| 38 | |
| 39 | if (Platform.CURRENT == Platform.MACOS) { |
| 40 | File library = _extract("/", "libjwm_" + arch + ".dylib", tempDir); |
| 41 | System.load(library.getAbsolutePath()); |
| 42 | } else if (Platform.CURRENT == Platform.WINDOWS) { |
| 43 | File library = _extract("/", "jwm_" + arch + ".dll", tempDir); |
| 44 | System.load(library.getAbsolutePath()); |
| 45 | } else if (Platform.CURRENT == Platform.X11) { |
| 46 | File library = _extract("/", "libjwm_" + arch + ".so", tempDir); |
| 47 | System.load(library.getAbsolutePath()); |
| 48 | } |
| 49 | |
| 50 | if (tempDir.exists() && version == null) { |
| 51 | Runtime.getRuntime().addShutdownHook(new Thread(() -> { |
| 52 | try { |
| 53 | Files.walk(tempDir.toPath()) |
| 54 | .map(Path::toFile) |
| 55 | .sorted(Comparator.reverseOrder()) |
| 56 | .forEach((f) -> { |
| 57 | f.delete(); |
| 58 | }); |
| 59 | } catch (IOException ex) { |
| 60 | ex.printStackTrace(); |
| 61 | } |
| 62 | })); |
| 63 | } |
| 64 | |
| 65 | _loaded = true; |
| 66 | _nAfterLoad(); |
| 67 | } |
| 68 | |
| 69 | @ApiStatus.Internal |
| 70 | @SneakyThrows |
no test coverage detected