fix: do not throw exception on X

This commit is contained in:
Johannes Frohnmeyer 2024-07-22 16:49:20 +02:00
parent c3dff152b1
commit 8a3971584b
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -27,15 +27,17 @@ public class Native {
} else if (System.getProperty("io.gitlab.jfronny.globalmenu.disable") != null) { } else if (System.getProperty("io.gitlab.jfronny.globalmenu.disable") != null) {
problem = "Explicitly disabled"; problem = "Explicitly disabled";
} else { } else {
String _problem = null;
try (InputStream is = Native.class.getResourceAsStream("/libnative.so")) { try (InputStream is = Native.class.getResourceAsStream("/libnative.so")) {
Path path = Files.createTempFile("libnative", ".so"); Path path = Files.createTempFile("libnative", ".so");
Files.copy(is, path, java.nio.file.StandardCopyOption.REPLACE_EXISTING); Files.copy(is, path, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
System.load(path.toString()); System.load(path.toString());
} catch (Exception e) { } catch (Throwable e) {
problem = "Failed to load native library: " + e.getMessage(); _problem = "Failed to load native library: " + e.getMessage();
throw new RuntimeException(e); // We can't log yet, because Idea will complain
// GlobalMenu.INSTANCE.getLog().error("Failed to load native library", e);
} }
problem = null; problem = _problem;
} }
} }