当前位置:网站首页>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
边栏推荐
- Flume interview questions
- 业务可视化-让你的流程图'Run'起来
- Introduction and download of the latest version of airserver2022
- Mysql——》索引存储模型推演
- Smart micro mm32 multi-channel adc-dma configuration
- Clean up system cache and free memory under Linux
- 多种智能指针
- PyTorch磨刀篇|argmax和argmin函数
- Qtreeview+qabstractitemmodel custom model: the third of a series of tutorials [easy to understand]
- 完全注解的ssm框架搭建
猜你喜欢
收到一封CTO来信,邀约面试机器学习工程师
QT版本华睿相机的Demo程序实现
Spark interview questions
黑马程序员-软件测试--06阶段2-linux和数据库-01-08第一章-linux操作系统阶段内容说明,linux命令基本格式以及常见形式的说明,操作系统的常见的分类,查看命令帮助信息方法,
Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
Mysql——》MyISAM存储引擎的索引
微软、哥伦比亚大学|GODEL:目标导向对话的大规模预训练
二叉树的基本操作
详解LockSupport的使用
Getting started with the lockust series
随机推荐
Mask wearing detection method based on yolov5
One of the basic learning of function
信标委云原生专题组组长,任重道远!
辅音和声母的区别?(声母与辅音的区别)
[ecological partner] Kunpeng system engineer training
CNN convolution neural network principle explanation + image recognition application (with source code) [easy to understand]
[noip2013] building block competition [noip2018] road laying greed / difference
Redis配置与优化
[intelligent QBD risk assessment tool] Shanghai daoning brings you leanqbd introduction, trial and tutorial
Airserver mobile phone third-party screen projection computer software
MySQL的视图练习题
BlocProvider 为什么感觉和 Provider 很相似?
牛客月赛-分组求对数和
互联网的智算架构设计
Training on the device with MIT | 256Kb memory
Using closures to switch toggle by clicking a button
【juc学习之路第9天】屏障衍生工具
Chapter 9 Yunji datacanvas company has been ranked top 3 in China's machine learning platform market
Use of vscode
Internet of things RFID, etc