当前位置:网站首页>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 :
边栏推荐
- 西安电子科技大学22学年上学期《信号与系统》试题及答案
- The latest tank battle 2022 - Notes on the whole development -2
- Tyut Taiyuan University of technology 2022 "Mao Gai" must be recited
- Caching mechanism of leveldb
- 2. Preliminary exercises of C language (2)
- (超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
- MPLS experiment
- 凡人修仙学指针-2
- View UI Plus 发布 1.2.0 版本,新增 Image、Skeleton、Typography组件
- Detailed explanation of redis' distributed lock principle
猜你喜欢
关于双亲委派机制和类加载的过程
8.C语言——位操作符与位移操作符
hashCode()与equals()之间的关系
5. Function recursion exercise
The overseas sales of Xiaomi mobile phones are nearly 140million, which may explain why Xiaomi ov doesn't need Hongmeng
5. Download and use of MSDN
受检异常和非受检异常的区别和理解
西安电子科技大学22学年上学期《基础实验》试题及答案
PriorityQueue (large root heap / small root heap /topk problem)
更改VS主题及设置背景图片
随机推荐
[modern Chinese history] Chapter 9 test
Mortal immortal cultivation pointer-2
View UI Plus 發布 1.3.1 版本,增强 TypeScript 使用體驗
1. C language matrix addition and subtraction method
编写程序,模拟现实生活中的交通信号灯。
9. Pointer (upper)
This time, thoroughly understand the MySQL index
hashCode()与equals()之间的关系
4.二分查找
vector
C语言入门指南
仿牛客技术博客项目常见问题及解答(三)
2. Preliminary exercises of C language (2)
Custom RPC project - frequently asked questions and explanations (Registration Center)
FileInputStream和BufferedInputStream的比较
5月14日杂谈
为什么要使用Redis
仿牛客技术博客项目常见问题及解答(二)
MySQL锁总结(全面简洁 + 图文详解)
Change vs theme and set background picture