当前位置:网站首页>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
边栏推荐
- [STM32] stm32cubemx tutorial II - basic use (new projects light up LED lights)
- 函数基本学习之一
- LIS (longest ascending subsequence) problem that can be understood [easy to understand]
- 【目标跟踪】|单目标跟踪指标
- BlocProvider 为什么感觉和 Provider 很相似?
- Yyds dry goods inventory # solve the real problem of famous enterprises: egg twisting machine
- [deep learning] use deep learning to monitor your girlfriend's wechat chat?
- Redis配置与优化
- 【单体】流辰信息I-BPSv3服务器推荐配置
- String type conversion BigDecimal, date type
猜你喜欢
mysql 学习笔记-优化之SQL优化
焱融看 | 混合云时代下,如何制定多云策略
【juc学习之路第9天】屏障衍生工具
ICML2022 | 基于元语义正则化的介入性对比学习
Icml2022 | interventional contrastive learning based on meta semantic regularization
收到一封CTO来信,邀约面试机器学习工程师
Introduction and download of the latest version of airserver2022
Chapter 9 Yunji datacanvas company has been ranked top 3 in China's machine learning platform market
配置筛选机
【MySQL】explain的基本使用以及各列的作用
随机推荐
List announced | outstanding intellectual property service team in China in 2021
One of the basic learning of function
Basic operation of binary tree
LIS (longest ascending subsequence) problem that can be understood [easy to understand]
【生态伙伴】鲲鹏系统工程师培训
Flume interview questions
PCB plug hole technology~
Clean up system cache and free memory under Linux
Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
【MySQL】数据库优化方法
【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!
Spark interview questions
收到一封CTO来信,邀约面试机器学习工程师
完全注解的ssm框架搭建
Why must digital transformation strategies include continuous testing?
Basic knowledge of ngnix
PHP reflective XSS, reflective XSS test and repair
Case of camera opening by tour
2020-ViT ICLR
详解Volatile关键字