当前位置:网站首页>类加载器及双亲委派机制
类加载器及双亲委派机制
2022-07-02 06:24:00 【软件开发随心记】
一、类加载器模型
有一个类Car,创建了3个实例:
打印3个car类hashcode,地址是不同的(356573597,1735600054,
21685669);但是通过这个这3个实例,获取原始类,地址是一致的(1956725890),说明这3个类来源的是同一个模板。
二、双亲委派机制
先说一下类加载器类型,一共有4种:
1.虚拟机加载器
2.启动类(根)加载器
3.扩展类加载器
4.应用程序(系统类)加载器
建一个java.lang下同名的String方法,打印测试,提示main方法找不到
这个是java保证安全的机制,java运行时,按以下顺序找类加载器:
1.类加载器收到类加载请求
2.将这个类加载请求向上委托给父类加载器去完成,一直向上委托,直到启动类加载器
3.启动类加载器检查能否加载当前这个类,能加载就结束,使用当前的加载器;否则,抛出异常,通知子类加载器进行加载
4.重复步骤3
5.所有加载器都未加载成功,则抛出异常:Class Not Found
本次找到的是jre\lib\rt.jar包下面的java.lang.String.toString()方法执行,这个方法是没有main方法的,所以报错,这样就能避免程序员误操作修改了java的标准包,保证了系统的安全性。
边栏推荐
- Ceaspectuss shipping company shipping artificial intelligence products, anytime, anywhere container inspection and reporting to achieve cloud yard, shipping company intelligent digital container contr
- Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance
- Build FRP for intranet penetration
- Explanation and application of annotation and reflection
- 数仓模型事实表模型设计
- ssm超市订单管理系统
- sqli-labs通关汇总-page4
- ORACLE EBS ADI 开发步骤
- Sqli-labs customs clearance (less15-less17)
- MySQL index
猜你喜欢
IDEA2020中PySpark的两表关联(字段名相同)
In depth study of JVM bottom layer (V): class loading mechanism
sqli-labs通关汇总-page4
TCP攻击
Sqli-labs customs clearance (less6-less14)
SQL injection closure judgment
Recursion (maze problem, Queen 8 problem)
Oracle apex Ajax process + dy verification
Explain in detail the process of realizing Chinese text classification by CNN
Sqli labs customs clearance summary-page3
随机推荐
Oracle EBS database monitoring -zabbix+zabbix-agent2+orabbix
oracle apex ajax process + dy 校验
php中在二维数组中根据值返回对应的键值
Principle analysis of spark
CSRF攻击
Huawei mindspire open source internship machine test questions
In depth study of JVM bottom layer (V): class loading mechanism
In depth study of JVM bottom layer (II): hotspot virtual machine object
js数组的常用的原型方法
Sqli labs customs clearance summary-page3
Improve user experience defensive programming
Redis -- cache breakdown, penetration, avalanche
Differences between ts and JS
php中时间戳转换为毫秒以及格式化时间
图解Kubernetes中的etcd的访问
Spark的原理解析
SQL injection closure judgment
php中生成随机的6位邀请码
搭建frp进行内网穿透
Oracle apex 21.2 installation and one click deployment