/** * 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; }
String packagePrefix = calculatePackagePrefix().replace('.', '_'); String name = packagePrefix + originalName; List<Throwable> suppressed = new ArrayList<Throwable>(); try { loadLibrary(loader, name, false); return; } catch (Throwable ex) { patchShadedLibraryId(bytes, originalName, name); closeQuietly(out); out = null; loadLibrary(loader, tmpFile.getPath(), true); } catch (UnsatisfiedLinkError e) { try { throw ule; } finally { closeQuietly(in); closeQuietly(out);
final byte[] classBinary = classToByteArray(helper); return AccessController.doPrivileged(new PrivilegedAction<Class<?>>() { @Override
try { final Class<?> newHelper = tryToLoadClass(loader, NativeLibraryUtil.class); loadLibraryByHelper(newHelper, name, absolute); logger.debug("Successfully loaded the library {}", name); return;
String name = calculatePackagePrefix().replace('.', '_') + originalName; List<Throwable> suppressed = new ArrayList<Throwable>(); try { loadLibrary(loader, name, false); return; } catch (Throwable ex) { closeQuietly(out); out = null; loadLibrary(loader, tmpFile.getPath(), true); } catch (UnsatisfiedLinkError e) { try { throw ule; } finally { closeQuietly(in); closeQuietly(out);
throw new ClassNotFoundException(clazz.getName(), ex); } finally { closeQuietly(in); closeQuietly(out);
private static void loadTcNative() throws Exception { String os = PlatformDependent.normalizedOs(); String arch = PlatformDependent.normalizedArch(); Set<String> libNames = new LinkedHashSet<String>(4); String staticLibName = "netty_tcnative"; // First, try loading the platform-specific library. Platform-specific // libraries will be available if using a tcnative uber jar. libNames.add(staticLibName + "_" + os + '_' + arch); if ("linux".equalsIgnoreCase(os)) { // Fedora SSL lib so naming (libssl.so.10 vs libssl.so.1.0.0).. libNames.add(staticLibName + "_" + os + '_' + arch + "_fedora"); } libNames.add(staticLibName + "_" + arch); libNames.add(staticLibName); NativeLibraryLoader.loadFirstAvailable(SSL.class.getClassLoader(), libNames.toArray(new String[0])); }
try { final Class<?> newHelper = tryToLoadClass(loader, NativeLibraryUtil.class); loadLibraryByHelper(newHelper, name, absolute); logger.debug("Successfully loaded the library {}", name); return;
String name = calculatePackagePrefix().replace('.', '_') + originalName; List<Throwable> suppressed = new ArrayList<Throwable>(); try { loadLibrary(loader, name, false); return; } catch (Throwable ex) { closeQuietly(out); out = null; loadLibrary(loader, tmpFile.getPath(), true); } catch (UnsatisfiedLinkError e) { try { throw ule; } finally { closeQuietly(in); closeQuietly(out);
throw new ClassNotFoundException(clazz.getName(), ex); } finally { closeQuietly(in); closeQuietly(out);
private static void loadTcNative() throws Exception { String os = PlatformDependent.normalizedOs(); String arch = PlatformDependent.normalizedArch(); Set<String> libNames = new LinkedHashSet<String>(4); String staticLibName = "netty_tcnative"; // First, try loading the platform-specific library. Platform-specific // libraries will be available if using a tcnative uber jar. libNames.add(staticLibName + "_" + os + '_' + arch); if ("linux".equalsIgnoreCase(os)) { // Fedora SSL lib so naming (libssl.so.10 vs libssl.so.1.0.0).. libNames.add(staticLibName + "_" + os + '_' + arch + "_fedora"); } libNames.add(staticLibName + "_" + arch); libNames.add(staticLibName); NativeLibraryLoader.loadFirstAvailable(SSL.class.getClassLoader(), libNames.toArray(new String[0])); }
String packagePrefix = calculatePackagePrefix().replace('.', '_'); String name = packagePrefix + originalName; List<Throwable> suppressed = new ArrayList<Throwable>(); try { loadLibrary(loader, name, false); return; } catch (Throwable ex) { patchShadedLibraryId(bytes, originalName, name); closeQuietly(out); out = null; loadLibrary(loader, tmpFile.getPath(), true); } catch (UnsatisfiedLinkError e) { try { throw ule; } finally { closeQuietly(in); closeQuietly(out);
try { final Class<?> newHelper = tryToLoadClass(loader, NativeLibraryUtil.class); loadLibraryByHelper(newHelper, name, absolute); logger.debug("Successfully loaded the library {}", name); return;
String name = calculatePackagePrefix().replace('.', '_') + originalName; List<Throwable> suppressed = new ArrayList<Throwable>(); try { loadLibrary(loader, name, false); return; } catch (Throwable ex) { closeQuietly(out); out = null; loadLibrary(loader, tmpFile.getPath(), true); } catch (UnsatisfiedLinkError e) { try { throw ule; } finally { closeQuietly(in); closeQuietly(out);
/** * 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; }
throw new ClassNotFoundException(clazz.getName(), ex); } finally { closeQuietly(in); closeQuietly(out);
final byte[] classBinary = classToByteArray(helper); return AccessController.doPrivileged(new PrivilegedAction<Class<?>>() { @Override
private static void loadTcNative() throws Exception { String os = PlatformDependent.normalizedOs(); String arch = PlatformDependent.normalizedArch(); Set<String> libNames = new LinkedHashSet<String>(4); String staticLibName = "netty_tcnative"; // First, try loading the platform-specific library. Platform-specific // libraries will be available if using a tcnative uber jar. libNames.add(staticLibName + "_" + os + '_' + arch); if ("linux".equalsIgnoreCase(os)) { // Fedora SSL lib so naming (libssl.so.10 vs libssl.so.1.0.0).. libNames.add(staticLibName + "_" + os + '_' + arch + "_fedora"); } libNames.add(staticLibName + "_" + arch); libNames.add(staticLibName); NativeLibraryLoader.loadFirstAvailable(SSL.class.getClassLoader(), libNames.toArray(new String[0])); }
String packagePrefix = calculatePackagePrefix().replace('.', '_'); String name = packagePrefix + originalName; List<Throwable> suppressed = new ArrayList<Throwable>(); try { loadLibrary(loader, name, false); return; } catch (Throwable ex) { patchShadedLibraryId(bytes, originalName, name); closeQuietly(out); out = null; loadLibrary(loader, tmpFile.getPath(), true); } catch (UnsatisfiedLinkError e) { try { throw ule; } finally { closeQuietly(in); closeQuietly(out);
try { final Class<?> newHelper = tryToLoadClass(loader, NativeLibraryUtil.class); loadLibraryByHelper(newHelper, name, absolute); logger.debug("Successfully loaded the library {}", name); return;