当前位置:网站首页>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 
边栏推荐
- Chapter 10 project communication management
- 大厂面试必问:如何解决TCP可靠传输问题?8张图带你详细学习
- 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
- 重磅!法大大上榜“专精特新”企业
- Beijiafu (p+f) R2000 modified radar IP
- Analyze the implementation process of oauth2 distributed authentication and authorization based on the source code
- Based on the codeless platform, users deeply participated in the construction, and digital data + Nanjing Fiberglass Institute jointly built a national smart laboratory solution
- 2022年安全员-A证考题及答案
- CSRF and SSRF for web attacks
- 堆內存分配的並發問題
猜你喜欢
![[QT] QT event handling](/img/48/14a5491307fee1c99434d6cb308337.jpg)
[QT] QT event handling

ThreadLocal local thread

High level application of SQL statements in MySQL database (I)

HTTP的缓存控制

Analyze the implementation process of oauth2 distributed authentication and authorization based on the source code

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

Redis-跳表

Beijiafu (p+f) R2000 modified radar IP

2022-06-10 work record --js- obtain the date n days after a certain date

YGG recent game partners list
随机推荐
String exercise summary 2
YGG recent game partners list
使用Aggregated APIServer扩展你的kubernetes API
Problem solving - nested lists
[QT] QT event handling
Future development of education industry of e-commerce Express
Technology inventory: Technology Evolution and Future Trend Outlook of cloud native Middleware
img2pdf
2022-06-10 work record --js- obtain the date n days after a certain date
Idea global search replace shortcut key
C language operators and expressions
Visitor tweets tell you which groups are consuming blind boxes
Data communication foundation - Ethernet port mirroring and link aggregation
Memory alignment of structures
2022-06-10 工作记录--JS-获取到某一日期N天后的日期
面试害怕被问MySQL相关问题 ?这份三万字精华总结 + 面试100 问,吊打面试官完全够了
[ingénierie logicielle] points clés à la fin de la période
倍加福(P+F)R2000修改雷达IP
Row and column differences in matrix construction of DX HLSL and GL glsl
Virtual private network foundation