??????????????
?????????????ClassLoader??????????壬????????????????????????????????JVM?????????????????????.class????????????????????????????????У????????????н???????????Class??????????????????????????????????????????????????????
?????????????????
??????Java?У????????????????????????????????????????????Java Doc?????????????????
????The ClassLoader class uses a delegation model to search for classes and resources. Each instance of ClassLoader has an associated parent class loader. When requested to find a class or resource?? a ClassLoader instance will delegate the search for the class or resource to its parent class loader before attempting to find the class or resource itself. The virtual machine's built-in class loader?? called the "bootstrap class loader"?? does not itself have a parent but may serve as the parent of a ClassLoader instance.
???????????????У???????????????????
????1??????????????????????
????2????? ClassLoader ?????????????????
????3?????????????????????????????????????????????
????4?????????????????????????????Bootstrap ClassLoader?????ü???????и????????????????????????????????????????
????Java ???????????????????????????????????????????C++????????????JVM??????????????????? <Java_Runtime_Home>/lib ???е?????????????????????????????????????? rt.jar??????????????????е???????????????? Java ?????????????????????????????????????ExtClassLoader????????????????AppClassLoader?????????????????????<Java_Runtime_Home>libext???л??????? java.ext.dirs ??????????е????????ó??????????????????????·???е??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

??????????︸??????????????????й????????????????????????
????????????????γ????????????????
????public class Test {
????}
????public class TestMain {
????public static void main(String[] args) {
????ClassLoader loader = Test.class.getClassLoader();
????while (loader!=null){
????System.out.println(loader);
????loader = loader.getParent();
????}
????}
????}
???????????????н?????????:

???????????????????????????£??????????????? AppClassLoader ?????AppClassLoader ?????????? ExtClassLoader?????? ExtClassLoader ??????????????????????????????????????????????????? JVM ???????????????? Java ??????????? Java ???????????????????????????????????????????? ExtClassLoader ?? ??????????????????????????????ο???????
????protected Class<?> loadClass(String name?? boolean resolve)
????throws ClassNotFoundException
????{
????synchronized (getClassLoadingLock(name)) {
????// First?? check if the class has already been loaded
????Class<?> c = findLoadedClass(name);
????if (c == null) {
????long t0 = System.nanoTime();
????try {
????if (parent != null) {
????c = parent.loadClass(name?? false);
????} else {
????c = findBootstrapClassOrNull(name);
????}
????} catch (ClassNotFoundException e) {
????// ClassNotFoundException thrown if class not found
????// from the non-null parent class loader
????}
????if (c == null) {
????// If still not found?? then invoke findClass in order
????// to find the class.
????long t1 = System.nanoTime();
????c = findClass(name);
????// this is the defining class loader; record the stats
????sun.misc.PerfCounter.getParentDelegationTime().addTime(t1 - t0);
????sun.misc.PerfCounter.getFindClassTime().addElapsedTimeFrom(t1);
????sun.misc.PerfCounter.getFindClasses().increment();
????}
????}
????if (resolve) {
????resolveClass(c);
????}
????return c;
????}
????}
?????????????????ExtClassLoader ?? AppClassLoader??????? ClassLoader ??ClassLoader ??????? loadClass ?????????????????????????????????????????????
????1???????????????????????
????2????δ????????ж???????????????????????????????????и?????????????????????????????????findBootstrapClassOrNull ????????????? native ????????
????3???????????????????????????????????
?????????????γ?????????????????????????????????????????????????????????
????????????????????????????????????Test????jar????????????? <Java_Runtime_Home>libext ???£?????????????????????????£?