当前位置:网站首页>类加载器及双亲委派机制
类加载器及双亲委派机制
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的标准包,保证了系统的安全性。
边栏推荐
- 解决微信小程序swiper组件bindchange事件抖动问题
- Changes in foreign currency bookkeeping and revaluation general ledger balance table (Part 2)
- oracle apex ajax process + dy 校验
- Implement strstr() II
- Sqli labs customs clearance summary-page1
- Oracle EBS interface development - quick generation of JSON format data
- Common function writing method and set get writing method for calculating attributes
- ORACLE EBS接口开发-json格式数据快捷生成
- CSRF攻击
- ORACLE 11.2.0.3 不停机处理SYSAUX表空间一直增长问题
猜你喜欢
Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance
sqli-labs通关汇总-page4
PgSQL learning notes
Basic knowledge of software testing
Take you to master the formatter of visual studio code
Sqli Labs clearance summary - page 2
Redis -- cache breakdown, penetration, avalanche
Review of reflection topics
Implement strstr() II
Analysis of MapReduce and yarn principles
随机推荐
IDEA2020中PySpark的两表关联(字段名相同)
Recursion (maze problem, Queen 8 problem)
Laravel8中的find_in_set、upsert的使用方法
Analysis of MapReduce and yarn principles
Principle analysis of spark
Data warehouse model fact table model design
In depth study of JVM bottom layer (V): class loading mechanism
Common prototype methods of JS array
PHP Session原理简析
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
ssm+mysql实现进销存系统
ORACLE EBS接口开发-json格式数据快捷生成
SQLI-LABS通关(less18-less20)
ORACLE 11G SYSAUX表空间满处理及move和shrink区别
Sqli labs customs clearance summary-page2
php中通过集合collect的方法来实现把某个值插入到数组中指定的位置
php中生成随机的6位邀请码
Differences between ts and JS
MySQL index
Explanation and application of annotation and reflection