java.lang.UnsatisfiedLinkError类的使用及代码示例

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

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

UnsatisfiedLinkError介绍

[英]Thrown when an attempt is made to invoke a native for which an implementation could not be found.
[中]当试图调用找不到其实现的本机时引发。

代码示例

代码示例来源: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: robovm/robovm

String filename = loader.findLibrary(libraryName);
  if (filename == null) {
    throw new UnsatisfiedLinkError("Couldn't load " + libraryName +
                    " from loader " + loader +
                    ": findLibrary returned null");
      return; // We successfully loaded the library. Job done.
    } catch (UnsatisfiedLinkError e) {
      lastError = e.getMessage();
  throw new UnsatisfiedLinkError(lastError);
throw new UnsatisfiedLinkError("Library " + libraryName + " not found; tried " + candidates);

代码示例来源:origin: pentaho/pentaho-kettle

public static boolean isJCoImplAvailableNotUsed() {
 try {
  Object c = Class.forName( JCO_IMPL_EXISTENCE_TEST_CLASS );
  if ( c == null ) {
   return false;
  }
  return true;
 } catch ( UnsatisfiedLinkError e ) {
  e.printStackTrace();
  return false;
 } catch ( NoClassDefFoundError e ) {
  e.printStackTrace();
  return false;
 } catch ( ClassNotFoundException e ) {
  e.printStackTrace();
  return false;
 } catch ( Exception e ) {
  e.printStackTrace();
  return false;
 } catch ( Throwable e ) {
  e.printStackTrace();
  return false;
 }
}

代码示例来源: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: eclipsesource/J2V8

static boolean load(final String libName, final StringBuffer message) {
  try {
    if (libName.indexOf(SEPARATOR) != -1) {
      System.load(libName);
    } else {
      System.loadLibrary(libName);
    }
    return true;
  } catch (UnsatisfiedLinkError e) {
    if (message.length() == 0) {
      message.append(DELIMITER);
    }
    message.append('\t');
    message.append(e.getMessage());
    message.append(DELIMITER);
  }
  return false;
}

代码示例来源:origin: bytedeco/javacpp

if (loadError != null && e.getCause() == null) {
  e.initCause(loadError);
  ex.initCause(loadError);
Error e = new UnsatisfiedLinkError(ex.toString());
e.initCause(ex);
if (logger.isDebugEnabled()) {

代码示例来源:origin: dodola/RocooFix

@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TextView test = (TextView)this.findViewById(R.id.test);
    TextView source = (TextView)this.findViewById(R.id.source);
    source.setText("请在如下路径放入so "+SoFileUtil.getSDCardSoPath().getAbsolutePath()+File.separator+SoFileUtil.getFullSoName("libhello-jni")+"  [请注意修改so文件名称]");
    TextView copyfrom = (TextView)this.findViewById(R.id.copyfrom);
    copyfrom.setText("so会被安装到"+SoFileUtil.getDataFileSoPatchForInstall(this).getAbsolutePath()+ File.separator+SoFileUtil.getFullSoName("libhello-jni")+"路径");
    String jniStr=null;
    try {
      jniStr=HelloJni.stringFromJNI();
      test.setText("读取so内容["+jniStr+"]");
    } catch (UnsatisfiedLinkError e) {
      e.printStackTrace();
      test.setText("##错误## "+e.getMessage());
    }
  }
}

代码示例来源: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: osmandapp/Osmand

log.error(e.getMessage(), e);
} catch (UnsatisfiedLinkError e) {
  log.error(e.getMessage(), e);

代码示例来源:origin: bytedeco/javacpp

throw new UnsatisfiedLinkError("Platform \"" + properties.getProperty("platform") + "\" not supported by " + cls);
  if (preloadError != null && e.getCause() == null) {
    e.initCause(preloadError);

代码示例来源: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

/**
 * 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: jMonkeyEngine/jmonkeyengine

throw new UnsatisfiedLinkError(
        "The required native library '" + name + "'"
        + " is not available for your OS: " + platform);
      throw new UnsatisfiedLinkError(
          "The required native library '" + unmappedName + "'"
          + " was not found in the classpath via '" + pathInJar
          + "'. Error message: " + e.getMessage());
    } else {
      logger.log(Level.FINE, "The optional native library ''{0}''" + 
                  " was not found in the classpath via ''{1}''" +
                  ". Error message: {2}",
                  new Object[]{unmappedName, pathInJar, e.getMessage()});
} catch (IOException ex) {
  throw new UnsatisfiedLinkError("Failed to open file: '" + url + 
                  "'. Error: " + ex);
    return;
  } else {
    throw new UnsatisfiedLinkError("Failed to extract native "
        + "library to: " + targetFile);

代码示例来源:origin: apache/hbase

LOG.debug("No JNI for codec '" + codecName + "' " + e.getMessage());
} catch (Exception e) {
 LOG.error(codecName, e);

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

/**
 * 通过connect函数测试TCP的RTT时延
 */
public boolean exec(String host) {
 if (isCConn && loaded) {
   try{
     startJNITelnet(host, "80"); //默认80端口
     return true;
   }catch(UnsatisfiedLinkError e){
     e.printStackTrace();
     Log.i("LDNetSocket", "call jni failed, call execUseJava");
     return execUseJava(host);
   }    
 } else {
  return execUseJava(host);
 }
}

代码示例来源: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: 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: net.java.dev.jna/jna

/** Look up the given global variable within this library.
 * @param symbolName
 * @return Pointer representing the global variable address
 * @throws UnsatisfiedLinkError if the symbol is not found
 */
public Pointer getGlobalVariableAddress(String symbolName) {
  try {
    return new Pointer(getSymbolAddress(symbolName));
  } catch(UnsatisfiedLinkError e) {
    throw new UnsatisfiedLinkError("Error looking up '" + symbolName + "': " + e.getMessage());
  }
}

代码示例来源:origin: bytedeco/javacpp

logger.debug(e.getMessage());

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

/**
 * 执行指定host的traceroute
 * 
 * @param host
 * @return
 */
public void startTraceRoute(String host) {
 if (isCTrace && loaded) {
  try {
   startJNICTraceRoute(host);
  } catch (UnsatisfiedLinkError e) {
   e.printStackTrace();
   // 如果c调用失败改调JAVA代码
   Log.i("LDNetTraceRoute", "调用java模拟traceRoute");
   TraceTask trace = new TraceTask(host, 1);
   execTrace(trace);
  }
 } else {
  TraceTask trace = new TraceTask(host, 1);
  execTrace(trace);
 }
}

相关文章