当前位置:网站首页>About the parental delegation mechanism and the process of class loading
About the parental delegation mechanism and the process of class loading
2022-07-06 13:39:00 【Wake up duck, did you program today?】
We wrote java File to final run , He must go through two stages of compilation and class loading , The process of compiling is to put
.java File compiled into .class file , The stage of class loading is to put .class File loading to JVM In memory , Loading finished
You'll get one Class object , We can use new Keyword to instantiate this object , Here's the picture :
The loading process of classes needs to involve
To class loader ,JVM When running, three class loaders will be generated , These three class loaders form a hierarchical relationship , Each loader loads different ranges of jar package , for instance Bootstrap Classloader( Start class loader )
It is mainly responsible for loading java The loading of the core class library is lib Under the table of contents rt.jar and resources.jar etc. ,Extension ClassLoader( Extend the classloader ) Main load lib\ext A... In the catalog jar Bao He class file ,Application ClassLoader( Apply the class loader ), Mainly responsible for the current application classpath All of the following jar Bao He class file , Besides the class loader provided by the processing system itself, you can also use ClassLoader Class to implement the custom loader , To meet the needs of some scenes .
The so-called parental delegation model , According to the hierarchical relationship of class loader , Delegate layer by layer , For example, when we need to load a class When you file , First of all, I will take this class The query and loading of files are delegated to the parent loader to execute , If the parent loader fails to load , Try to load this by yourself class
I think such benefits :
- Security : Because this hierarchical relationship actually represents a kind of priority , That is, all class loading priority should be given to the startup class loader , Then there is no way to destroy some classes in the core class library , For example, write a java.lang.String Finally, it is up to the boot class loader , His writing java.lang.String There is no way to cover the classes in the class library .
- I think this kind of hierarchical design relationship , It can avoid some problems of program confusion caused by repeated loading , If the parent loader has already been loaded , Then there is no need to load the sub loader .
The running result shows :
边栏推荐
- Questions and answers of "basic experiment" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
- 4.二分查找
- fianl、finally、finalize三者的区别
- FAQs and answers to the imitation Niuke technology blog project (I)
- FileInputStream和BufferedInputStream的比较
- The latest tank battle 2022 full development notes-1
- Aurora system model of learning database
- 2.C语言矩阵乘法
- JS interview questions (I)
- 【毕业季·进击的技术er】再见了,我的学生时代
猜你喜欢
1.C语言矩阵加减法
IPv6 experiment
Data manipulation language (DML)
C language to achieve mine sweeping game (full version)
编写程序,模拟现实生活中的交通信号灯。
甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1
Tyut Taiyuan University of technology 2022 "Mao Gai" must be recited
学编程的八大电脑操作,总有一款你不会
5. Function recursion exercise
3.猜数字游戏
随机推荐
fianl、finally、finalize三者的区别
MySQL事务及实现原理全面总结,再也不用担心面试
【九阳神功】2018复旦大学应用统计真题+解析
3. Number guessing game
There is always one of the eight computer operations that you can't learn programming
Comparison between FileInputStream and bufferedinputstream
Application architecture of large live broadcast platform
4. Binary search
2.C语言矩阵乘法
[graduation season · advanced technology Er] goodbye, my student days
学编程的八大电脑操作,总有一款你不会
9. Pointer (upper)
View UI Plus 发布 1.3.0 版本,新增 Space、$ImagePreview 组件
C language Getting Started Guide
9.指针(上)
【九阳神功】2019复旦大学应用统计真题+解析
5月14日杂谈
The latest tank battle 2022 - full development notes-3
JS interview questions (I)
ROS machine voice