类加载器
类加载器的作用
代码如下
public class Test07 {
public static void main(String[] args) throws ClassNotFoundException {
//获取系统类的加载器
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
System.out.println(systemClassLoader);
//获取系统类加载器的父类加载器-->扩展类加载器
ClassLoader parent = systemClassLoader.getParent();
System.out.println(parent);
//获取扩展类加载器的父类加载器-->根加载器(C/c++)
ClassLoader parent1 = parent.getParent();
System.out.println(parent1);
//测试当前类是哪个加载器加载的
ClassLoader classLoader = Class.forName("com.lu.reflection.Test07").getClassLoader();
System.out.println(classLoader);
//测试JDK内置的类是谁加载的
classLoader = Class.forName("java.lang.Object").getClassLoader();
System.out.println(classLoader);
//如何获得系统类加载器可以加载的路径
System.out.println(System.getProperty("java.class.path"));
//双亲委派机制
//多重检测安全性
//java.lang.String -->
/*
C:Program FilesJavajdk1.8.0_231jrelibcharsets.jar;
C:Program FilesJavajdk1.8.0_231jrelibdeploy.jar;
C:Program FilesJavajdk1.8.0_231jrelibextaccess-bridge-64.jar;
C:Program FilesJavajdk1.8.0_231jrelibextcldrdata.jar;
C:Program FilesJavajdk1.8.0_231jrelibextdnsns.jar;
C:Program FilesJavajdk1.8.0_231jrelibextjaccess.jar;
C:Program FilesJavajdk1.8.0_231jrelibextjfxrt.jar;
C:Program FilesJavajdk1.8.0_231jrelibextlocaledata.jar;
C:Program FilesJavajdk1.8.0_231jrelibext
ashorn.jar;
C:Program FilesJavajdk1.8.0_231jrelibextsunec.jar;
C:Program FilesJavajdk1.8.0_231jrelibextsunjce_provider.jar;
C:Program FilesJavajdk1.8.0_231jrelibextsunmscapi.jar;
C:Program FilesJavajdk1.8.0_231jrelibextsunpkcs11.jar;
C:Program FilesJavajdk1.8.0_231jrelibextzipfs.jar;
C:Program FilesJavajdk1.8.0_231jrelibjavaws.jar;
C:Program FilesJavajdk1.8.0_231jrelibjce.jar;
C:Program FilesJavajdk1.8.0_231jrelibjfr.jar;
C:Program FilesJavajdk1.8.0_231jrelibjfxswt.jar;
C:Program FilesJavajdk1.8.0_231jrelibjsse.jar;
C:Program FilesJavajdk1.8.0_231jrelibmanagement-agent.jar;
C:Program FilesJavajdk1.8.0_231jrelibplugin.jar;
C:Program FilesJavajdk1.8.0_231jrelib
esources.jar;
C:Program FilesJavajdk1.8.0_231jrelib
t.jar;
C:Users99714DesktopJavaSEoutproduction基础语法;
C:Users99714DesktopJavaSE基础语法srccomlibcommons-io-2.7.jar;
D:IntelliJ IDEA 2019.2.4libidea_rt.jar
*/
}
}