当前位置:网站首页>JVM有哪些类加载机制?
JVM有哪些类加载机制?
2022-07-01 21:47:00 【詹Sir(开源字节)】
JVM类加载机制有哪些?
1、全盘负责,当一个类加载器负责加载某个Class时,该Class所依赖的和引用的其他Class也将由该类加载器负责载入,除非显示使用另外一个类加载器来载入
2、父类委托,先让父类加载器试图加载该类,只有在父类加载器无法加载该类时才尝试从自己的类路径中加载该类
3、缓存机制,缓存机制将会保证所有加载过的Class都会被缓存,当程序中需要使用某个Class时,类加载器先从缓存区寻找该Class,只有缓存区不存在,系统才会读取该类对应的二进制数据,并将其转换成Class对象,存入缓存区。这就是为什么修改了Class后,必须重启JVM,程序的修改才会生效
4、双亲委派机制, 如果一个类加载器收到了类加载的请求,它首先不会自己去尝试加载这个类,而是把请求委托给父加载器去完成,依次向上,因此,所有的类加载请求最终都应该被传递到顶层的启动类加载器中,只有当父加载器在它的搜索范围中没有找到所需的类时,即无法完成该加载,子加载器才会尝试自己去加载该类。
双亲委派机制过程?
1、当AppClassLoader加载一个class时,它首先不会自己去尝试加载这个类,而是把类加载请求委派给父类加载器ExtClassLoader去完成。
2、当ExtClassLoader加载一个class时,它首先也不会自己去尝试加载这个类,而是把类加载请求委派给BootStrapClassLoader去完成。
3、如果BootStrapClassLoader加载失败(例如在$JAVA_HOME/jre/lib里未查找到该class),会使用ExtClassLoader来尝试加载;
4、若ExtClassLoader也加载失败,则会使用AppClassLoader来加载,如果AppClassLoader也加载失败,则会报出异常ClassNotFoundException。
如若转载,请注明出处:开源字节 https://sourcebyte.cn/article/174.html
边栏推荐
- Simple interactive operation of electron learning (III)
- 【MySQL】索引的创建、查看和删除
- 详解JMM
- Learning notes on futuretask source code of concurrent programming series
- Airserver mobile phone third-party screen projection computer software
- Microsoft, Columbia University | Godel: large scale pre training of goal oriented dialogue
- In the past 100 years, only 6 products have been approved, which is the "adjuvant" behind the vaccine competition
- Redis配置与优化
- [intelligent QBD risk assessment tool] Shanghai daoning brings you leanqbd introduction, trial and tutorial
- Getting started with the lockust series
猜你喜欢

详解Kubernetes网络模型

Mask wearing detection method based on yolov5

Sonic cloud real machine learning summary 6 - 1.4.1 server and agent deployment

企业架构与项目管理的关联和区别

【MySQL】索引的分类

详解JMM
Design and practice of new generation cloud native database

AirServer2022最新版功能介绍及下载

Mysql——》Innodb存储引擎的索引

JS how to get a list of elements in a collection object
随机推荐
比较版本号[双指针截取自己想要的字串]
LIS (longest ascending subsequence) problem that can be understood [easy to understand]
【MySQL】explain的基本使用以及各列的作用
内存导致的电脑游戏中显示hdmi无信号 从而死机的情况
详解JMM
互联网的智算架构设计
记录一次spark on yarn 任务报错 Operation category READ is not supported in state standby
Fundamentals - IO intensive computing and CPU intensive computing
多种智能指针
Copy ‘XXXX‘ to effectively final temp variable
地图其他篇总目录
Show member variables and methods in classes in idea
EasyExcel 复杂数据导出
RestTemplate 远程调用工具类
[live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!
Go - exe corresponding to related dependency
Case of camera opening by tour
AirServer2022最新版功能介绍及下载
[noip2013] building block competition [noip2018] road laying greed / difference
详解Volatile关键字