package com.ioc; public class Test { public static void main(String[] args) throws ClassNotFoundException { System.out.println(Test.class.getClassLoader()); System.out.println(ClassLoader.getSystemClassLoader()); System.out.println(ClassLoader.getSystemClassLoader()); System.out.println(Thread.currentThread().getContextClassLoader()); //System.out.println(Test.class.getClassLoader().loadClass("com.ioc.Test2"));//没有初始化 //System.out.println(Class.forName("com.ioc.Test2"));//开始初始化 System.out.println (the Class.forName ( "com.ioc.Test2", to false , ClassLoader.getSystemClassLoader ())); // not initialized } }
Package com.ioc; public class Test2 { static { System.out.println ( "start initialization" ); } }
ClassLoader depth understanding of the working mechanism (jdk1.8)
https://blog.csdn.net/u014634338/article/details/81434327