java.lang.UnsatisfiedLinkError.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中java.lang.UnsatisfiedLinkError.<init>()方法的一些代码示例,展示了UnsatisfiedLinkError.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UnsatisfiedLinkError.<init>()方法的具体详情如下:
包路径:java.lang.UnsatisfiedLinkError
类名称:UnsatisfiedLinkError
方法名:<init>

UnsatisfiedLinkError.<init>介绍

[英]Constructs a new UnsatisfiedLinkError that includes the current stack trace.
[中]构造包含当前堆栈跟踪的新UnsatifiedLinkError。

代码示例

代码示例来源:origin: netty/netty

/**
 * The shading prefix added to this class's full name.
 *
 * @throws UnsatisfiedLinkError if the shader used something other than a prefix
 */
private static String calculatePackagePrefix() {
  String maybeShaded = NativeLibraryLoader.class.getName();
  // Use ! instead of . to avoid shading utilities from modifying the string
  String expected = "io!netty!util!internal!NativeLibraryLoader".replace('!', '.');
  if (!maybeShaded.endsWith(expected)) {
    throw new UnsatisfiedLinkError(String.format(
        "Could not find prefix added to %s to get %s. When shading, only adding a "
        + "package prefix is supported", expected, maybeShaded));
  }
  return maybeShaded.substring(0, maybeShaded.length() - expected.length());
}

代码示例来源:origin: redisson/redisson

/**
 * Ensure that <a href="http://netty.io/wiki/native-transports.html">{@code netty-transport-native-kqueue}</a> is
 * available.
 *
 * @throws UnsatisfiedLinkError if unavailable
 */
public static void ensureAvailability() {
  if (UNAVAILABILITY_CAUSE != null) {
    throw (Error) new UnsatisfiedLinkError(
        "failed to load the required native library").initCause(UNAVAILABILITY_CAUSE);
  }
}

代码示例来源:origin: redisson/redisson

/**
 * Ensure that <a href="http://netty.io/wiki/native-transports.html">{@code netty-transport-native-epoll}</a> is
 * available.
 *
 * @throws UnsatisfiedLinkError if unavailable
 */
public static void ensureAvailability() {
  if (UNAVAILABILITY_CAUSE != null) {
    throw (Error) new UnsatisfiedLinkError(
        "failed to load the required native library").initCause(UNAVAILABILITY_CAUSE);
  }
}

代码示例来源:origin: redisson/redisson

/**
 * Ensure that <a href="http://netty.io/wiki/forked-tomcat-native.html">{@code netty-tcnative}</a> and
 * its OpenSSL support are available.
 *
 * @throws UnsatisfiedLinkError if unavailable
 */
public static void ensureAvailability() {
  if (UNAVAILABILITY_CAUSE != null) {
    throw (Error) new UnsatisfiedLinkError(
        "failed to load the required native library").initCause(UNAVAILABILITY_CAUSE);
  }
}

代码示例来源:origin: eclipsesource/J2V8

public static String getName() {
    final String archProperty = System.getProperty("os.arch");
    final String archName = normalizeArch(archProperty);
    if (archName.equals(Platform.UNKNOWN)) {
      throw new UnsatisfiedLinkError("Unsupported arch: " + archProperty);
    }
    return archName;
  }
}

代码示例来源:origin: redisson/redisson

/**
 * The shading prefix added to this class's full name.
 *
 * @throws UnsatisfiedLinkError if the shader used something other than a prefix
 */
private static String calculatePackagePrefix() {
  String maybeShaded = NativeLibraryLoader.class.getName();
  // Use ! instead of . to avoid shading utilities from modifying the string
  String expected = "io!netty!util!internal!NativeLibraryLoader".replace('!', '.');
  if (!maybeShaded.endsWith(expected)) {
    throw new UnsatisfiedLinkError(String.format(
        "Could not find prefix added to %s to get %s. When shading, only adding a "
        + "package prefix is supported", expected, maybeShaded));
  }
  return maybeShaded.substring(0, maybeShaded.length() - expected.length());
}

代码示例来源:origin: netty/netty

private static void loadLibraryByHelper(final Class<?> helper, final String name, final boolean absolute)
    throws UnsatisfiedLinkError {
  Object ret = AccessController.doPrivileged(new PrivilegedAction<Object>() {
    @Override
    public Object run() {
      try {
        // Invoke the helper to load the native library, if succeed, then the native
        // library belong to the specified ClassLoader.
        Method method = helper.getMethod("loadLibrary", String.class, boolean.class);
        method.setAccessible(true);
        return method.invoke(null, name, absolute);
      } catch (Exception e) {
        return e;
      }
    }
  });
  if (ret instanceof Throwable) {
    Throwable t = (Throwable) ret;
    assert !(t instanceof UnsatisfiedLinkError) : t + " should be a wrapper throwable";
    Throwable cause = t.getCause();
    if (cause instanceof UnsatisfiedLinkError) {
      throw (UnsatisfiedLinkError) cause;
    }
    UnsatisfiedLinkError ule = new UnsatisfiedLinkError(t.getMessage());
    ule.initCause(t);
    throw ule;
  }
}

代码示例来源:origin: iBotPeaches/Apktool

public static void load(String libPath) {
  if (mLoaded.contains(libPath)) {
    return;
  }
  File libFile;
  try {
    libFile = getResourceAsFile(libPath);
  } catch (BrutException ex) {
    throw new UnsatisfiedLinkError(ex.getMessage());
  }
  System.load(libFile.getAbsolutePath());
}

代码示例来源:origin: wildfly/wildfly

/**
 * Ensure that <a href="http://netty.io/wiki/forked-tomcat-native.html">{@code netty-tcnative}</a> and
 * its OpenSSL support are available.
 *
 * @throws UnsatisfiedLinkError if unavailable
 */
public static void ensureAvailability() {
  if (UNAVAILABILITY_CAUSE != null) {
    throw (Error) new UnsatisfiedLinkError(
        "failed to load the required native library").initCause(UNAVAILABILITY_CAUSE);
  }
}

代码示例来源:origin: eclipsesource/J2V8

public static String getName() {
  final String osProperty = System.getProperty("os.name");
  final String osName = normalizeOs(osProperty);
  final String vendorProperty = System.getProperty("java.specification.vendor");
  final String vendorName = normalize(vendorProperty);
  // special handling for android
  if (vendorName.contains("android") || osName.contains("android")) {
    return Platform.ANDROID;
  }
  if (osName.equals(Platform.UNKNOWN)) {
    throw new UnsatisfiedLinkError("Unsupported platform/vendor: " + osProperty + " / " + vendorProperty);
  }
  return osName;
}

代码示例来源:origin: wildfly/wildfly

/**
 * Ensure that <a href="http://netty.io/wiki/native-transports.html">{@code netty-transport-native-kqueue}</a> is
 * available.
 *
 * @throws UnsatisfiedLinkError if unavailable
 */
public static void ensureAvailability() {
  if (UNAVAILABILITY_CAUSE != null) {
    throw (Error) new UnsatisfiedLinkError(
        "failed to load the required native library").initCause(UNAVAILABILITY_CAUSE);
  }
}

代码示例来源:origin: wildfly/wildfly

/**
 * Ensure that <a href="http://netty.io/wiki/native-transports.html">{@code netty-transport-native-epoll}</a> is
 * available.
 *
 * @throws UnsatisfiedLinkError if unavailable
 */
public static void ensureAvailability() {
  if (UNAVAILABILITY_CAUSE != null) {
    throw (Error) new UnsatisfiedLinkError(
        "failed to load the required native library").initCause(UNAVAILABILITY_CAUSE);
  }
}

代码示例来源:origin: wildfly/wildfly

/**
 * The shading prefix added to this class's full name.
 *
 * @throws UnsatisfiedLinkError if the shader used something other than a prefix
 */
private static String calculatePackagePrefix() {
  String maybeShaded = NativeLibraryLoader.class.getName();
  // Use ! instead of . to avoid shading utilities from modifying the string
  String expected = "io!netty!util!internal!NativeLibraryLoader".replace('!', '.');
  if (!maybeShaded.endsWith(expected)) {
    throw new UnsatisfiedLinkError(String.format(
        "Could not find prefix added to %s to get %s. When shading, only adding a "
        + "package prefix is supported", expected, maybeShaded));
  }
  return maybeShaded.substring(0, maybeShaded.length() - expected.length());
}

代码示例来源:origin: io.netty/netty

/**
 * Ensure that <a href="http://netty.io/wiki/forked-tomcat-native.html">{@code netty-tcnative}</a> and
 * its OpenSSL support are available.
 *
 * @throws UnsatisfiedLinkError if unavailable
 */
public static void ensureAvailability() {
  if (UNAVAILABILITY_CAUSE != null) {
    throw (Error) new UnsatisfiedLinkError(
        "failed to load the required native library").initCause(UNAVAILABILITY_CAUSE);
  }
}

代码示例来源:origin: redisson/redisson

private static void loadLibraryByHelper(final Class<?> helper, final String name, final boolean absolute)
    throws UnsatisfiedLinkError {
  Object ret = AccessController.doPrivileged(new PrivilegedAction<Object>() {
    @Override
    public Object run() {
      try {
        // Invoke the helper to load the native library, if succeed, then the native
        // library belong to the specified ClassLoader.
        Method method = helper.getMethod("loadLibrary", String.class, boolean.class);
        method.setAccessible(true);
        return method.invoke(null, name, absolute);
      } catch (Exception e) {
        return e;
      }
    }
  });
  if (ret instanceof Throwable) {
    Throwable t = (Throwable) ret;
    assert !(t instanceof UnsatisfiedLinkError) : t + " should be a wrapper throwable";
    Throwable cause = t.getCause();
    if (cause instanceof UnsatisfiedLinkError) {
      throw (UnsatisfiedLinkError) cause;
    }
    UnsatisfiedLinkError ule = new UnsatisfiedLinkError(t.getMessage());
    ule.initCause(t);
    throw ule;
  }
}

代码示例来源:origin: eclipsesource/J2V8

private static String getLinuxOsReleaseId() {
  // First, look for the os-release file.
  for (String osReleaseFileName : LINUX_OS_RELEASE_FILES) {
    File file = new File(osReleaseFileName);
    if (file.exists()) {
      return parseLinuxOsReleaseFile(file);
    }
  }
  // Older versions of redhat don't have /etc/os-release. In this case, try
  // parsing this file.
  File file = new File(REDHAT_RELEASE_FILE);
  if (file.exists()) {
    return parseLinuxRedhatReleaseFile(file);
  }
  throw new UnsatisfiedLinkError("Unsupported linux vendor: " + getName());
}

代码示例来源:origin: robovm/robovm

public static long resolveBridge(String libraryName, String symbol, Method method) {
  long handle = getHandle(libraryName);
  long f = Dl.resolve(handle, symbol);
  if (f == 0L) {
    f = Dl.resolve(handle, UNHIDDEN_SYMBOL_PREFIX + symbol);
  }
  if (f == 0L) {
    throw new UnsatisfiedLinkError("Failed to resolve native function " + symbol
        + "for method " + method + " in library " + libraryName);
  }
  return f;
}

代码示例来源:origin: robovm/robovm

public static long resolveBridge(Library library, Bridge bridge, Method method) {
  if (library == null) {
    throw new IllegalArgumentException("No @" + Library.class.getName() 
        + " annotation found on class " + method.getDeclaringClass().getName());
  }
  
  long handle = getHandle(library.value());
  String symbol = bridge.symbol();
  if (symbol == null || "".equals(symbol)) {
    symbol = method.getName();
  }
  long f = Dl.resolve(handle, symbol);
  if (f == 0L) {
    f = Dl.resolve(handle, UNHIDDEN_SYMBOL_PREFIX + symbol);
  }
  if (f == 0L && !bridge.optional()) {
    throw new UnsatisfiedLinkError("Failed to resolve native function '" + symbol + "' " 
        + "for method " + method + " with @Bridge annotation " + bridge 
        + " in library " + library);
  }
  return f;
}

代码示例来源:origin: eclipsesource/J2V8

public static String getName() {
  if (OS.isWindows()) {
    return "microsoft";
  }
  if (OS.isMac()) {
    return "apple";
  }
  if (OS.isLinux()) {
    return getLinuxOsReleaseId();
  }
  if (OS.isAndroid()) {
    return "google";
  }
  throw new UnsatisfiedLinkError("Unsupported vendor: " + getName());
}

代码示例来源:origin: eclipsesource/J2V8

public static String getLibFileExtension() {
    if (isWindows()) {
      return "dll";
    }
    if (isMac()) {
      return "dylib";
    }
    if (isLinux()
      || isAndroid()
      || isNativeClient()) {
      return "so";
    }
    throw new UnsatisfiedLinkError("Unsupported platform library-extension for: " + getName());
  }
}

相关文章