当前位置:网站首页>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 
边栏推荐
- 结构体的内存对齐
- Problem solving - nested lists
- 重磅!法大大上榜“专精特新”企业
- Selection and comparison of message oriented middleware MQ
- ACL (access control list) basic chapter - Super interesting learning network
- Idea global search replace shortcut key
- 【Mongodb】READ_ME_TO_RECOVER_YOUR_DATA,数据库被恶意删除
- Technology inventory: Technology Evolution and Future Trend Outlook of cloud native Middleware
- Learning bit segment (1)
- Data communication and physical network
猜你喜欢

Power system | IEEE paper submission process

ThreadLocal内存泄漏问题

Creating files, recursively creating directories
![[personal experiment report]](/img/04/c9e1bee19bff9d55b73c531f7b17f4.png)
[personal experiment report]

Principles of Ethernet port mirroring, link aggregation and VLAN Technology

How to integrate Huawei cloud function services in fluent

详细了解Redis的八种数据类型及应用场景分析

vulnhub Vegeta: 1

Technology inventory: past, present and future of Message Oriented Middleware
CA Zhouji - the first lesson in 2022 rust
随机推荐
Idea close global search box
The difference between get and post
Yyds dry goods inventory junit5 learning II: assumptions class
【WSL】SSH 远程连接及宿主机端口转发配置
Leetcode algorithm The first common node of two linked lists
LeetCode Algorithm 剑指 Offer 52. 两个链表的第一个公共节点
Visitor tweets tell you which groups are consuming blind boxes
Learn more about redis' eight data types and application scenario analysis
Creating files, recursively creating directories
JMM 最最最核心的概念:Happens-before 原则
Use of selector for NiO multiplexing
CA Zhouji - the first lesson in 2022 rust
Extend your kubernetes API with aggregated apiserver
1. fully explain the basic principles of IPSec
In the era of full programming, should I give up this road?
VRRP skills topic
2022-06-10 工作记录--JS-获取到某一日期N天后的日期
Interrupt, interrupted, isinterrupted differences
Genesis公链与美国一众加密投资者齐聚Consensus 2022
Dynamic memory management (1)