/** * Loads the first available library in the collection with the specified * {@link ClassLoader}. * * @throws IllegalArgumentException * if none of the given libraries load successfully. */ public static void loadFirstAvailable(ClassLoader loader, String... names) { List<Throwable> suppressed = new ArrayList<Throwable>(); for (String name : names) { try { load(name, loader); return; } catch (Throwable t) { suppressed.add(t); logger.debug("Unable to load the library '{}', trying next name...", name, t); } } IllegalArgumentException iae = new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names)); ThrowableUtil.addSuppressedAndClear(iae, suppressed); throw iae; }
/** * Loads the first available library in the collection with the specified * {@link ClassLoader}. * * @throws IllegalArgumentException * if none of the given libraries load successfully. */ public static void loadFirstAvailable(ClassLoader loader, String... names) { List<Throwable> suppressed = new ArrayList<Throwable>(); for (String name : names) { try { load(name, loader); return; } catch (Throwable t) { suppressed.add(t); logger.debug("Unable to load the library '{}', trying next name...", name, t); } } IllegalArgumentException iae = new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names)); ThrowableUtil.addSuppressedAndClear(iae, suppressed); throw iae; }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("mac") && !name.contains("bsd") && !name.startsWith("darwin")) { throw new IllegalStateException("Only supported on BSD"); } String staticLibName = "netty_transport_native_kqueue"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("linux")) { throw new IllegalStateException("Only supported on Linux"); } String staticLibName = "netty_transport_native_epoll"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
/** * Loads the first available library in the collection with the specified * {@link ClassLoader}. * * @throws IllegalArgumentException * if none of the given libraries load successfully. */ public static void loadFirstAvailable(ClassLoader loader, String... names) { List<Throwable> suppressed = new ArrayList<Throwable>(); for (String name : names) { try { load(name, loader); return; } catch (Throwable t) { suppressed.add(t); logger.debug("Unable to load the library '{}', trying next name...", name, t); } } IllegalArgumentException iae = new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names)); ThrowableUtil.addSuppressedAndClear(iae, suppressed); throw iae; }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("mac") && !name.contains("bsd") && !name.startsWith("darwin")) { throw new IllegalStateException("Only supported on BSD"); } String staticLibName = "netty_transport_native_kqueue"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("linux")) { throw new IllegalStateException("Only supported on Linux"); } String staticLibName = "netty_transport_native_epoll"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
/** * Loads the first available library in the collection with the specified * {@link ClassLoader}. * * @throws IllegalArgumentException * if none of the given libraries load successfully. */ public static void loadFirstAvailable(ClassLoader loader, String... names) { List<Throwable> suppressed = new ArrayList<Throwable>(); for (String name : names) { try { load(name, loader); return; } catch (Throwable t) { suppressed.add(t); logger.debug("Unable to load the library '{}', trying next name...", name, t); } } IllegalArgumentException iae = new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names)); ThrowableUtil.addSuppressedAndClear(iae, suppressed); throw iae; }
/** * Loads the first available library in the collection with the specified * {@link ClassLoader}. * * @throws IllegalArgumentException * if none of the given libraries load successfully. */ public static void loadFirstAvailable(ClassLoader loader, String... names) { List<Throwable> suppressed = new ArrayList<Throwable>(); for (String name : names) { try { load(name, loader); return; } catch (Throwable t) { suppressed.add(t); logger.debug("Unable to load the library '{}', trying next name...", name, t); } } IllegalArgumentException iae = new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names)); ThrowableUtil.addSuppressedAndClear(iae, suppressed); throw iae; }
/** * Loads the first available library in the collection with the specified * {@link ClassLoader}. * * @throws IllegalArgumentException * if none of the given libraries load successfully. */ public static void loadFirstAvailable(ClassLoader loader, String... names) { List<Throwable> suppressed = new ArrayList<Throwable>(); for (String name : names) { try { load(name, loader); return; } catch (Throwable t) { suppressed.add(t); logger.debug("Unable to load the library '{}', trying next name...", name, t); } } IllegalArgumentException iae = new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names)); ThrowableUtil.addSuppressedAndClear(iae, suppressed); throw iae; }
/** * Loads the first available library in the collection with the specified * {@link ClassLoader}. * * @throws IllegalArgumentException * if none of the given libraries load successfully. */ public static void loadFirstAvailable(ClassLoader loader, String... names) { List<Throwable> suppressed = new ArrayList<Throwable>(); for (String name : names) { try { load(name, loader); return; } catch (Throwable t) { suppressed.add(t); logger.debug("Unable to load the library '{}', trying next name...", name, t); } } IllegalArgumentException iae = new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names)); ThrowableUtil.addSuppressedAndClear(iae, suppressed); throw iae; }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("mac") && !name.contains("bsd") && !name.startsWith("darwin")) { throw new IllegalStateException("Only supported on BSD"); } String staticLibName = "netty_transport_native_kqueue"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("mac") && !name.contains("bsd") && !name.startsWith("darwin")) { throw new IllegalStateException("Only supported on BSD"); } String staticLibName = "netty_transport_native_kqueue"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("mac") && !name.contains("bsd") && !name.startsWith("darwin")) { throw new IllegalStateException("Only supported on BSD"); } String staticLibName = "netty_transport_native_kqueue"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("mac") && !name.contains("bsd") && !name.startsWith("darwin")) { throw new IllegalStateException("Only supported on BSD"); } String staticLibName = "netty_transport_native_kqueue"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("linux")) { throw new IllegalStateException("Only supported on Linux"); } String staticLibName = "netty_transport_native_epoll"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("linux")) { throw new IllegalStateException("Only supported on Linux"); } String staticLibName = "netty_transport_native_epoll"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("linux")) { throw new IllegalStateException("Only supported on Linux"); } String staticLibName = "netty_transport_native_epoll"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }