JVM class loader ----- parents delegate mechanism

First, I want to ask you a question, we can not own definition of java and a core package of the same package name when writing a program, write code in this application.
That can not write a package java.lang own definition of a String class to write code? The answer of course is no.
To repeat java class is loaded and the safety procedures to prevent certain types of malicious hackers modified so that intrusion into the program, devised a security sandbox mechanism, that is, parents delegate mechanism.
Next, I briefly explain the class loader java:
java in class loader is divided into three: start class loader (BootStrapClassLoader), extended class loader (ExtensionClassLoader), application class loader (ApplicationClassLoader), there is a custom loader (requires users to achieve)


Start class loader (BootStrapClassLoader) : ++ implemented by c, is responsible for loading JAVA_HOME / jre / lib in rt.jar in the library, where we had stored rt.jar core system libraries, such as String, starting class loader is not visible.

Extension class loader (ExtensionClassLoader) : responsible for loading the JAVA_HOME / jre / lib library directory under the ext /.

Application class loader (ApplicationClassLoader) : responsible for loading the library on the user (classpath).

Note: The three classes java not use inheritance, but the use of a combination of relationship.
Here Insert Picture Description
Here Insert Picture Description
Parents delegate mechanism: it simply is not working to find a father son, father nor grandfather to find work. When a class is loaded first use BootStrapClassLoader loaded, loaded by the ExtensionClassLoader when BootStrapClassLoader do nothing, and then loaded by ApplicationClassLoader when ExtensionClassLoader can not do anything, throw ClassNotFoundException when all loaders are unable to load

A white understanding welcome the god of correction

Guess you like

Origin blog.csdn.net/weixin_45118251/article/details/90582803