Class loading is done by the ClassLoader, which includes the root loader (BootStrap), the extension loader (Extension), the system loader (systems), and the user-defined class loader (subclass Java.lang.ClassLoader). Starting with Java 2 (JDK 1.2), the class loading process takes the Father delegation mechanism (PDM). PDM better guarantees the security of the Java platform, in which the JVM's own Bootstrap is the root loader, and the other loaders have only one parent class loader. The load of a class first requests that the parent ClassLoader be loaded, and the parent ClassLoader is not loaded by its child ClassLoader. The JVM does not provide a reference to the Bootstrap to the Java program.
1)Bootstrap ClassLoader负责加载$JAVA_HOME中jre/lib/rt.jar里所有的class,由C++实现,不是ClassLoader子类2)Extension ClassLoader负责加载java平台中扩展功能的一些jar包,包括$JAVA_HOME中jre/lib/*.jar或-Djava.ext.dirs指定目录下的jar包3)App ClassLoader负责记载classpath中指定的jar包及目录中class4)Custom ClassLoader属于应用程序根据自身需要自定义的ClassLoader,如tomcat、jboss都会根据j2ee规范自行实现ClassLoader加载过程中会先检查类是否被已加载,检查顺序是自底向上,从Custom ClassLoader到BootStrap ClassLoader逐层检查,只要某个classloader已加载就视为已加载此类,保证此类只所有ClassLoader加载一次。而加载的顺序是自顶向下,也就是由上层来逐层尝试加载此类。
The class loader in Java