java.lang.ClassLoader.findLibrary()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(202)

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

ClassLoader.findLibrary介绍

[英]Returns the absolute path of the native library with the specified name, or null. If this method returns null then the virtual machine searches the directories specified by the system property "java.library.path".

This implementation always returns null.
[中]返回具有指定名称或null的本机库的绝对路径。如果此方法返回null,则虚拟机将搜索系统属性“java.library.path”指定的目录。
此实现始终返回null。

代码示例

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

String filename = loader.findLibrary(libraryName);
if (filename == null) {
  throw new UnsatisfiedLinkError("Couldn't load " + libraryName +

代码示例来源:origin: Silverpeas/Silverpeas-Core

@Override
protected String findLibrary(String libname) {
 return super.findLibrary(libname);
}

代码示例来源:origin: org.wildfly.openssl/wildfly-openssl-java

@Override
protected String findLibrary(String libname) {
  final String mapped = System.mapLibraryName(libname);
  for (String path : Identification.NATIVE_SEARCH_PATHS) {
    String complete = path + "/" + mapped;
    try {
      try (final InputStream resource = SSL.class.getClassLoader().getResourceAsStream(complete)) {
        if (resource != null) {
          File temp = File.createTempFile("tmp-", "openssl");
          temp.delete();
          temp.mkdir();
          File result = new File(temp, mapped);
          try (FileOutputStream out = new FileOutputStream(result)) {
            byte[] buf = new byte[1000];
            int r;
            while ((r = resource.read(buf)) > 0) {
              out.write(buf, 0, r);
            }
          }
          result.deleteOnExit();
          temp.deleteOnExit();
          return result.getAbsolutePath();
        }
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
  return super.findLibrary(libname);
}

代码示例来源:origin: org.wildfly.openssl/wildfly-openssl

@Override
protected String findLibrary(String libname) {
  final String mapped = System.mapLibraryName(libname);
  for (String path : Identification.NATIVE_SEARCH_PATHS) {
    String complete = path + "/" + mapped;
    try {
      try (final InputStream resource = SSL.class.getClassLoader().getResourceAsStream(complete)) {
        if (resource != null) {
          File temp = File.createTempFile("tmp-", "openssl");
          temp.delete();
          temp.mkdir();
          File result = new File(temp, mapped);
          try (FileOutputStream out = new FileOutputStream(result)) {
            byte[] buf = new byte[1000];
            int r;
            while ((r = resource.read(buf)) > 0) {
              out.write(buf, 0, r);
            }
          }
          result.deleteOnExit();
          temp.deleteOnExit();
          return result.getAbsolutePath();
        }
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
  return super.findLibrary(libname);
}

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

String filename = loader.findLibrary(libraryName);
if (filename == null) {
  throw new UnsatisfiedLinkError("Couldn't load " + libraryName +

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

String filename = loader.findLibrary(libraryName);
if (filename == null) {
  throw new UnsatisfiedLinkError("Couldn't load " + libraryName +

代码示例来源:origin: ibinti/bugvm

String filename = loader.findLibrary(libraryName);
if (filename == null) {
  throw new UnsatisfiedLinkError("Couldn't load " + libraryName +

代码示例来源:origin: com.gluonhq/robovm-rt

String filename = loader.findLibrary(libraryName);
if (filename == null) {
  throw new UnsatisfiedLinkError("Couldn't load " + libraryName +

代码示例来源:origin: com.bugvm/bugvm-rt

String filename = loader.findLibrary(libraryName);
if (filename == null) {
  throw new UnsatisfiedLinkError("Couldn't load " + libraryName +

代码示例来源:origin: FlexoVM/flexovm

String filename = loader.findLibrary(libraryName);
if (filename == null) {
  throw new UnsatisfiedLinkError("Couldn't load " + libraryName +

代码示例来源:origin: kumuluz/kumuluzee

@Override
protected String findLibrary(String name) {
  debug(String.format("findLibrary: %s", name));
  if (isLaunchedFromJar()) {
    JarEntryInfo jarEntryInfo = findJarNativeEntry(name);
    if (jarEntryInfo != null) {
      try {
        File file = createJarFile(jarEntryInfo);
        debug(String.format("Loading native library %s from temp file %s", jarEntryInfo.getJarEntry(), getFilenameForLog(file)));
        deleteOnExit.add(file);
        return file.getAbsolutePath();
      } catch (EeClassLoaderException e) {
        debug(String.format("Failure to load native library %s: %s", name, e.toString()));
      }
    }
    return null;
  }
  return super.findLibrary(name);
}

代码示例来源:origin: com.kumuluz.ee/kumuluzee-loader

@Override
protected String findLibrary(String name) {
  debug(String.format("findLibrary: %s", name));
  if (isLaunchedFromJar()) {
    JarEntryInfo jarEntryInfo = findJarNativeEntry(name);
    if (jarEntryInfo != null) {
      try {
        File file = createJarFile(jarEntryInfo);
        debug(String.format("Loading native library %s from temp file %s", jarEntryInfo.getJarEntry(), getFilenameForLog(file)));
        deleteOnExit.add(file);
        return file.getAbsolutePath();
      } catch (EeClassLoaderException e) {
        debug(String.format("Failure to load native library %s: %s", name, e.toString()));
      }
    }
    return null;
  }
  return super.findLibrary(name);
}

相关文章