当前位置:网站首页>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 :
边栏推荐
- MySQL limit x, -1 doesn't work, -1 does not work, and an error is reported
- C语言入门指南
- 3. C language uses algebraic cofactor to calculate determinant
- 仿牛客技术博客项目常见问题及解答(一)
- 13 power map
- ArrayList的自动扩容机制实现原理
- [modern Chinese history] Chapter V test
- 12 excel charts and arrays
- Arduino+ds18b20 temperature sensor (buzzer alarm) +lcd1602 display (IIC drive)
- 8. C language - bit operator and displacement operator
猜你喜欢
(超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
Quickly generate illustrations
C language Getting Started Guide
C语言实现扫雷游戏(完整版)
There is always one of the eight computer operations that you can't learn programming
Arduino+ds18b20 temperature sensor (buzzer alarm) +lcd1602 display (IIC drive)
C language Getting Started Guide
1. C language matrix addition and subtraction method
[面试时]——我如何讲清楚TCP实现可靠传输的机制
1.C语言矩阵加减法
随机推荐
5月27日杂谈
仿牛客技术博客项目常见问题及解答(一)
C language to achieve mine sweeping game (full version)
学编程的八大电脑操作,总有一款你不会
5. Download and use of MSDN
Floating point comparison, CMP, tabulation ideas
Thoroughly understand LRU algorithm - explain 146 questions in detail and eliminate LRU cache in redis
Custom RPC project - frequently asked questions and explanations (Registration Center)
Data manipulation language (DML)
vector
A comprehensive summary of MySQL transactions and implementation principles, and no longer have to worry about interviews
[during the interview] - how can I explain the mechanism of TCP to achieve reliable transmission
Redis实现分布式锁原理详解
View UI Plus 发布 1.3.1 版本,增强 TypeScript 使用体验
6.函数的递归
2.初识C语言(2)
5.MSDN的下载和使用
Questions and answers of "signal and system" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
[au cours de l'entrevue] - Comment expliquer le mécanisme de transmission fiable de TCP
arduino+水位传感器+led显示+蜂鸣器报警