标签:类加载器 arch contex classpath str 信息 hiera load tostring
先调用当前线程的context加载器的getResourceAsStream方法去获取
没找到,在调用当前传入类的类加载器的getResourceAsStream方法获取
public static InputStream getResourceAsStream(Class clazz, String name) { InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); if (in == null) { in = clazz.getResourceAsStream(name); } return in; }
private static String showClassLoaderHierarchy(ClassLoader cl, String delim, String tabText, int indent) { if (cl == null) { String s = "null classloader " + delim; ClassLoader ctxcl = Thread.currentThread().getContextClassLoader(); s += "Context class loader=" + ctxcl + " hc=" + ctxcl.hashCode(); return s; } StringBuilder s = new StringBuilder(); //"ClassLoader: "; for (int i = 0; i < indent; i++) { s.append(tabText); } s.append(cl).append(" hc=").append(cl.hashCode()).append(delim); ClassLoader parent = cl.getParent(); return s.toString() + showClassLoaderHierarchy(parent, delim, tabText, indent + 1); }
标签:类加载器 arch contex classpath str 信息 hiera load tostring
原文地址:https://www.cnblogs.com/chenpi/p/9501222.html