当前位置:网站首页>Parental delegation mechanism
Parental delegation mechanism
2022-06-24 22:50:00 【Swarford】
Every time ⼀ Both classes have ⼀ A corresponding ClassLoader Class loader , The classloader is in ⼯ It will default to ⽤ Parent delegate mechanism ;
ClassLoader The specific role of will be class The bytecode file is loaded into jvm Go to the virtual machine , The program will run correctly ;
however ,jvm Starting does not load all at once class file , It's loading dynamically as needed ;
The so-called parental delegation mechanism , It's called ClassLoader Of loadClass( ) The rules of :
The specific process :
- The first step is the application class loader , call findLoadedClass( ) Check whether this class loader has loaded this class ,
- If not , Find out if there is parent The superior , If there is a superior, the superior's loadclass( ) Continue to find , It's like recursion
- until parent The superior is null( Start class loader C++), Delegate the start class loader to call findBootstrapClassOrNull( ) stay jre/lib In the catalog jar Start looking for classes in the package
- If the boot class loader is not found , Will report a mistake
ClassNotFoundException, Expand the class loader catch Exceptions are caught , Just before the extension class loader calls findClass()( Rewritten per loader ) Look up the directory jre/lib/ext;
If not , Will report a mistakeClassNotFoundException, Application class loader's catch Exceptions are caught , Finally, call the application class loader's own findClass( ) To classpath Find the class under the directory


Why check from bottom to top ?
To avoid repeated loading ;
In some cases, the parental delegation mechanism will be broken :
JDBC Of DriverManager By default, it is loaded by the boot class loader , But there is no... In the boot class loader Mysql Drive class , So the call to be displayed Class Of forName Method uses an application class loader to load Mysql Driver class 
边栏推荐
- DX 的 HLSL 和 GL 的 GLSL的 矩阵构建的行列区别
- Kubevela v1.2 release: the graphical operation console velaux you want is finally here
- In the multi network card environment, the service IP registered by Nacos is incorrect, resulting in inaccessible services
- LeetCode Algorithm 剑指 Offer 52. 两个链表的第一个公共节点
- Data center basic network platform
- Talk about GC mechanism often asked in interview
- [ingénierie logicielle] points clés à la fin de la période
- Fanuc robot_ Introduction to Karel programming (1)
- Cache control of HTTP
- 证件照处理
猜你喜欢

Solve the problem of non secure websites requesting localhost to report CORS after chrome94

In the multi network card environment, the service IP registered by Nacos is incorrect, resulting in inaccessible services

envoy获取客户端真实IP

重磅!法大大上榜“专精特新”企业

Introduction to machine learning compilation course learning notes lesson 1 overview of machine learning compilation

Unable to use the bean introduced into the jar package

vulnhub Vegeta: 1

Nuscenes -- remedies for missing image files or 0-size images encountered during dataset configuration

O (n) complexity hand tear sorting interview questions | an article will help you understand counting sorting

Genesis public chain and a group of encryption investors in the United States gathered in consensus 2022
随机推荐
Idea close global search box
证件照处理
Chapter 10 project stakeholder management
CA Zhouji - the first lesson in 2022 rust
Solve the problem of non secure websites requesting localhost to report CORS after chrome94
2022-06-16 work record --js- judge the number of digits in string type digits + judge the number of digits in numeric type digits + limit the text length (display n words at most, exceeding...)
Principle of IP routing
How to compare two or more distributions: a summary of methods from visualization to statistical testing
双亲委派机制
vulnhub Vegeta: 1
详细了解关于sentinel的实际应用
Talk about GC mechanism often asked in interview
[ingénierie logicielle] points clés à la fin de la période
Leetcode algorithm The first common node of two linked lists
LeetCode Algorithm 剑指 Offer 52. 两个链表的第一个公共节点
JWT(Json Web Token)
How to automatically remove all . orig files in Mercurial working tree?
Beijiafu (p+f) R2000 modified radar IP
Cat write multiline content to file
Visitor tweets tell you which groups are consuming blind boxes