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

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

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

ClassLoader.getUnnamedModule介绍

暂无

代码示例

代码示例来源:origin: org.tentackle/tentackle-common

/**
 * Creates an input stream from a resource.
 *
 * @param caller the caller class, null to determine via Stackwalker
 * @param name the resource name
 * @return the input stream
 * @throws IOException if reading the resources failed
 * @throws FileNotFoundException if no such resources found
 */
public static InputStream createInputStream(Class<?> caller, String name) throws IOException {
 if (caller == null) {
  caller = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass();
 }
 InputStream is = caller.getResourceAsStream(name);
 if (is == null) {
  // try other variant
  is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
  if (is == null) {
   Module module = caller.getClassLoader().getUnnamedModule();
   if (module != null) {
    is = module.getResourceAsStream(name);
   }
   if (is == null) {
    throw new FileNotFoundException("no such resource: " + name);
   }
  }
 }
 is = new BufferedInputStream(is);
 return is;
}

代码示例来源:origin: bytemanproject/byteman

extraReads.add(AccessEnabler.class.getModule());
extraReads.add(ClassLoader.getPlatformClassLoader().getUnnamedModule());
extraReads.add(ClassLoader.getSystemClassLoader().getUnnamedModule());

代码示例来源:origin: bytemanproject/byteman

extraReads.add(AccessEnabler.class.getModule());
extraReads.add(ClassLoader.getPlatformClassLoader().getUnnamedModule());
extraReads.add(ClassLoader.getSystemClassLoader().getUnnamedModule());

相关文章