当前位置:网站首页>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 
边栏推荐
- Genesis公链与美国一众加密投资者齐聚Consensus 2022
- Talk about GC mechanism often asked in interview
- The ktp900f mobile download program of the fail safe mobile panel prompts that the download cannot be performed, and the target device is running or not in the transmission mode
- Relationnet++: a representation of fusion of multiple detection targets based on transformer | neurips 2020
- Firewall working principle and detailed conversation table
- 大厂面试必问:如何解决TCP可靠传输问题?8张图带你详细学习
- 2022-06-16 工作记录--JS-判断字符串型数字有几位 + 判断数值型数字有几位 + 限制文本长度(最多展示n个字,超出...)
- 2022-06-10 工作记录--JS-获取到某一日期N天后的日期
- 电力系统| IEEE论文投稿流程
- Programmers become gods by digging holes in one year, carrying flags in five years and becoming gods in ten years
猜你喜欢

How to automatically remove all . orig files in Mercurial working tree?

2022-06-10 工作记录--JS-获取到某一日期N天后的日期

【Laravel系列7.9】测试

Heavyweight! Fada is listed as a "specialized and new" enterprise

Chapter 10 project communication management

环境配置 | VS2017配置OpenMesh源码和环境

Stop using it indiscriminately. This is the real difference between @validated and @valid!!!

NIO、BIO、AIO

Redis-跳表

开发规范~参数校验异常、异常返回提示切面
随机推荐
OSPF basic content
详细了解关于sentinel的实际应用
Learn more about redis' eight data types and application scenario analysis
【Laravel系列7.9】测试
Attackg: constructing technical knowledge graph from cyber thread intelligence reports
Cache control of HTTP
See how sparksql supports enterprise level data warehouse
FANUC机器人_KAREL编程入门学习(1)
MySQL + JSON = King fried!!
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
[personal experiment report]
ThreadLocal local thread
环境配置 | VS2017配置OpenMesh源码和环境
How to integrate Huawei cloud function services in fluent
Source code reading | the process of reading text format STL by openmesh
Seven principles of software design
堆內存分配的並發問題
【个人实验报告】
2022-06-10 work record --js- obtain the date n days after a certain date