I want to create custom class loader. But I am confused with loadClass(), does this method loads the specified class into memory?
If yes then why does the static block of the specified class is not invoked?
//main class
package custom_class_loader1;
public class Custom_class_loader1 {
public static void main(String[] args) {
try{
CustomClassLoader c=new CustomClassLoader();
Class c1= c.loadClass("custom_class_loader1.ABC");/**does this load ABC class into memory?**/
}catch(Exception e)
{
System.out.println(e);
}
}
}
When you load a class it doesn’t initalise it until it is used by default.
Here
falsemeans don’t resolve the class.One way to control this is to use the Class.forName()
prints