当前位置:网站首页>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 :

边栏推荐
- 为什么要使用Redis
- Set container
- 12 excel charts and arrays
- 7.数组、指针和数组的关系
- Arduino+ds18b20 temperature sensor (buzzer alarm) +lcd1602 display (IIC drive)
- 仿牛客技术博客项目常见问题及解答(一)
- Rich Shenzhen people and renting Shenzhen people
- Floating point comparison, CMP, tabulation ideas
- MySQL Database Constraints
- (原创)制作一个采用 LCD1602 显示的电子钟,在 LCD 上显示当前的时间。显示格式为“时时:分分:秒秒”。设有 4 个功能键k1~k4,功能如下:(1)k1——进入时间修改。
猜你喜欢

仿牛客技术博客项目常见问题及解答(三)

MySQL lock summary (comprehensive and concise + graphic explanation)

View UI Plus 发布 1.2.0 版本,新增 Image、Skeleton、Typography组件

优先队列PriorityQueue (大根堆/小根堆/TopK问题)

13 power map

2. Preliminary exercises of C language (2)

Custom RPC project - frequently asked questions and explanations (Registration Center)

Data manipulation language (DML)

MySQL Database Constraints

MySQL事务及实现原理全面总结,再也不用担心面试
随机推荐
[graduation season · advanced technology Er] goodbye, my student days
最新坦克大战2022-全程开发笔记-1
【九阳神功】2016复旦大学应用统计真题+解析
13 power map
3.猜数字游戏
FAQs and answers to the imitation Niuke technology blog project (I)
使用Spacedesk实现局域网内任意设备作为电脑拓展屏
一段用蜂鸣器编的音乐(成都)
【九阳神功】2020复旦大学应用统计真题+解析
杂谈0516
[面試時]——我如何講清楚TCP實現可靠傳輸的機制
强化学习系列(一):基本原理和概念
2.初识C语言(2)
C语言实现扫雷游戏(完整版)
hashCode()与equals()之间的关系
FAQs and answers to the imitation Niuke technology blog project (II)
9. Pointer (upper)
9.指针(上)
Thoroughly understand LRU algorithm - explain 146 questions in detail and eliminate LRU cache in redis
Smart classroom solution and mobile teaching concept description