Home > Java > javaTutorial > Detailed explanation of the classLoader class loading mechanism in JAVA development

Detailed explanation of the classLoader class loading mechanism in JAVA development

无忌哥哥
Release: 2018-07-18 11:25:15
Original
1873 people have browsed it

jvm has three class loaders, a user-defined loader, from top to bottom:

bootstrap classLoader This class loader loads the jdk core class library when the java virtual machine starts Load into memory

extension classLoader extension class loader, this class loader is a class library that loads some jars of jre

system classLoader system class loader, this class loader loads the classpath Specify the class library to the memory

custom classLoader User-defined class loader, the class loader is the responsibility of the programmer himself to dynamically load class files through the subclass of java.lang.classLoader during the running of the program

Loading mechanism:

The Java class loading mechanism is called the parent delegation mechanism: when there is a request to the loader for a class, it will first query from the bottom up whether the class has been loaded into the memory. If it is Loading will directly return the class. If not, then first delegate the parent class loader to load the class. If the current loader still has a parent class, then delegate to the next higher level until the top level. Only when the parent class cannot load the class, It will return to the next level until it is loaded. If it cannot be loaded, a class not found exception (ClassNotFoundException) will be returned. For example: when the user-defined loader is required to load the java.lang.String class, the bootstrap classLoader is actually used to load it. Because java.lang.String is the core library class of jdk, when the user-defined loader is used, it will be loaded. Delegate to the parent class loader first.

The above is the detailed content of Detailed explanation of the classLoader class loading mechanism in JAVA development. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template