zoukankan      html  css  js  c++  java
  • 类加载器详解

    package com.yang.jvm;
    
    import sun.net.spi.nameservice.dns.DNSNameService;
    
    public class Test {
        public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
            System.out.println(System.getProperty("sun.boot.class.path")); //bootStrap启动类的加载路径
            System.out.println(System.getProperty("java.ext.dirs")); //拓展类的加载路径
            System.out.println(System.getProperty("java.class.path"));  //应用类或者说是系统类的加载路径
            //因为字节码是使用类加载器加载的,所以每个字节码都会记录加载该字节码的类加载器,所以就可以通过字节码的getClassLoader()获得类加载器
            System.out.println(String.class.getClassLoader());//启动类加载器使用的是C或C++语言写的,所以打印启动类加载器都是返回null,
            System.out.println(DNSNameService.class.getClassLoader());//输出的是拓展类加载器sun.misc.Launcher$ExtClassLoader@2f333739
            System.out.println(Test.class.getClassLoader());//应用类加载器sun.misc.Launcher$AppClassLoader@14dad5dc
    
    
        }
    }
    

      

  • 相关阅读:
    Linux rpm 安装MySQL
    AOP 底层实现原理
    7 AOP
    HTTP 协议
    Oracle JDBC 标准连接实例
    Oracle JDBC 连接池
    Anaconda XGBoost安装
    Anaconda Spyder 导入自定义函数(模块)
    Hive常用sql
    决策树之信息增益计算模拟
  • 原文地址:https://www.cnblogs.com/yangxiaohui227/p/11582810.html
Copyright © 2011-2022 走看看