From fad8716cc830fe1d7ca8b3b3224afab1e6a7e45a Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 2 Oct 2015 09:27:51 +0200 Subject: [PATCH] Only try to load winpthread on windows Previously, it was loaded in any case, and errors were ignored (in an ineffective way leading to failures on non-windows). --- src/bindings/java/org/simgrid/msg/Msg.java | 9 ++------- src/bindings/java/org/simgrid/surf/SurfJNI.java | 5 ++--- src/bindings/java/surf.i | 5 ++--- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/bindings/java/org/simgrid/msg/Msg.java b/src/bindings/java/org/simgrid/msg/Msg.java index c442da4260..f47e945316 100644 --- a/src/bindings/java/org/simgrid/msg/Msg.java +++ b/src/bindings/java/org/simgrid/msg/Msg.java @@ -16,14 +16,9 @@ public final class Msg { public static void nativeInit() { if (isNativeInited) return; - try { + + if (System.getProperty("os.name").toLowerCase().startsWith("win")) NativeLib.nativeInit("winpthread"); - } catch (Exception e) { - if (System.getProperty("os.name").toLowerCase().startsWith("win")) { - System.err.println("Cannot load winpthread.dll:"); - e.printStackTrace(); - } - } NativeLib.nativeInit("simgrid"); NativeLib.nativeInit("simgrid-java"); diff --git a/src/bindings/java/org/simgrid/surf/SurfJNI.java b/src/bindings/java/org/simgrid/surf/SurfJNI.java index ec066f3e1a..abd3a25f48 100644 --- a/src/bindings/java/org/simgrid/surf/SurfJNI.java +++ b/src/bindings/java/org/simgrid/surf/SurfJNI.java @@ -13,9 +13,8 @@ import org.simgrid.NativeLib; public class SurfJNI { static { - try { - NativeLib.nativeInit("winpthread"); - } catch (Exception e) {} + if (System.getProperty("os.name").toLowerCase().startsWith("win")) + NativeLib.nativeInit("winpthread"); NativeLib.nativeInit("simgrid"); NativeLib.nativeInit("surf-java"); Runtime.getRuntime().addShutdownHook( diff --git a/src/bindings/java/surf.i b/src/bindings/java/surf.i index 13d23a93ca..f5ef7097fd 100644 --- a/src/bindings/java/surf.i +++ b/src/bindings/java/surf.i @@ -16,9 +16,8 @@ import org.simgrid.NativeLib; %} %pragma(java) jniclasscode=%{ static { - try { - NativeLib.nativeInit("winpthread"); - } catch (Exception e) {} + if (System.getProperty("os.name").toLowerCase().startsWith("win")) + NativeLib.nativeInit("winpthread"); NativeLib.nativeInit("simgrid"); NativeLib.nativeInit("surf-java"); Runtime.getRuntime().addShutdownHook( -- 2.20.1