JVM内置三大类加载器详细介绍

1.根加类载器
2.扩展类加载器
3.系统类加载器

代码演示

SimpleObject类

package com.dwz.classLoader.chapter1;

public class SimpleObject {
    
}

加载器

package com.dwz.classLoader.chapter1;
/**
 *    加载器
 */
public class BootClassLoader {
    public static void main(String[] args) throws ClassNotFoundException {
        //根加载器
        System.out.println(System.getProperty("sun.boot.class.path"));
        //扩展类加载器
        System.out.println(System.getProperty("java.ext.dirs"));
        
        Class<?> forName = Class.forName("com.dwz.classLoader.chapter1.SimpleObject");
        //类加载器(AppClassLoader)
        System.out.println(forName.getClassLoader());
        //类加载器的父类是扩展类加载器(ExtClassLoader)
        System.out.println(forName.getClassLoader().getParent());
        //由于根加载器是用c++写的,所以是个null
        System.out.println(forName.getClassLoader().getParent().getParent());
    }
}
posted @ 2020-01-14 10:59  龙宇在天  阅读(2033)  评论(0编辑  收藏  举报
//右侧添加目录 //增加页面点击显示24字社会主义核心价值观