标签:java classloader bootstrap 类加载 父类加载机制
java的类加载有两个重点,一是动态加载,一是父类加载。动态加载是指只有首次构建某个类的对象或者访问某个类的静态方法或者静态域的时候该类才会被加载。protected synchronized Class<?> loadClass (String name, boolean resolve) throws ClassNotFoundException{ // First check if the class is already loaded Class c = findLoadedClass(name); if (c == null) { try { if (parent != null) { c = parent.loadClass(name, false); } else { c = findBootstrapClass0(name); } } catch (ClassNotFoundException e) { // If still not found, then invoke // findClass to find the class. c = findClass(name); } } if (resolve) { resolveClass(c); } return c; }从以上代码中可以看出,JAVA类加载的过程如下:
标签:java classloader bootstrap 类加载 父类加载机制
原文地址:http://blog.csdn.net/yizhishl/article/details/38401273