/**
* 类加载器
* 1.Bootstrap类加载器
* 2.ExtClassLoader类加载器
* 3.AppClassLoader类加载器
*/
public class AaaController {
public static void main(String[] args) {
//jdk/bin/jre/rt.jar 中的.java类 被Bootstrap类加载器加载
ClassLoader classLoader1 = String.class.getClassLoader();
System.out.println(classLoader1);
//null,jvm启动直接加载到虚拟机中的,因为c语言写的,不是java写的,故为null
//com.sun.nio.zipfs.JarFileSystemProvider(zipfs.jar) jdk/bin/jre/ext文件夹中的jar被ExtClassLoader加载
ClassLoader classLoader3 = JarFileSystemProvider.class.getClassLoader();
System.out.println(classLoader3);
//sun.misc.Launcher$ExtClassLoader@2d6a9952
//其它即不在rt.jar,也不在jdk/bin/jre/ext的jar被AppClassLoader加载
ClassLoader classLoader4 = DelegatingPluginUIToolkit.class.getClassLoader();
System.out.println(classLoader4);
//sun.misc.Launcher$AppClassLoader@18b4aac2
//自己写的类也是被AppClassLoader加载
ClassLoader classLoader5 = AaaController.class.getClassLoader();
System.out.println(classLoader5);
//sun.misc.Launcher$AppClassLoader@18b4aac2
}
}