Understanding the working mechanism ClassLoader

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

Five minutes to read ClassLoader

https://www.jianshu.com/p/554c138ca0f5

Guess you like

Origin www.cnblogs.com/tonggc1668/p/11752781.html