当前位置:网站首页>类加载器及双亲委派机制
类加载器及双亲委派机制
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的标准包,保证了系统的安全性。
边栏推荐
- sqli-labs通关汇总-page4
- ORACLE APEX 21.2安装及一键部署
- JS to determine whether there is a value in the object in the array
- Go common compilation fails
- php中计算树状结构数据中的合计
- flex九宫格布局
- Use of interrupt()
- PXC high availability cluster summary
- Sqli labs customs clearance summary-page2
- Cloud picture says | distributed transaction management DTM: the little helper behind "buy buy buy"
猜你喜欢

Explain in detail the process of realizing Chinese text classification by CNN

ORACLE EBS ADI 开发步骤

MySQL中的正则表达式

Basic knowledge of software testing

SQLI-LABS通关(less1)

User login function: simple but difficult

Analysis of MapReduce and yarn principles

Brief analysis of PHP session principle

2021-07-05C#/CAD二次开发创建圆弧(4)

UEditor .Net版本任意文件上传漏洞复现
随机推荐
Sentry construction and use
SQLI-LABS通关(less18-less20)
pm2简单使用和守护进程
Anti shake and throttling of JS
[leetcode question brushing day 35] 1060 Missing element in ordered array, 1901 Find the peak element, 1380 Lucky number in matrix
sqli-labs通关汇总-page2
sqli-labs通关汇总-page3
Date time API details
Changes in foreign currency bookkeeping and revaluation general ledger balance table (Part 2)
[daily question] - Huawei machine test 01
CVE-2015-1635(MS15-034 )遠程代碼執行漏洞複現
Only the background of famous universities and factories can programmers have a way out? Netizen: two, big factory background is OK
PHP Session原理简析
Yolov5 practice: teach object detection by hand
oracle-外币记账时总账余额表gl_balance变化(上)
sqli-labs通關匯總-page2
ORACLE 11.2.0.3 不停机处理SYSAUX表空间一直增长问题
JS to determine whether there is a value in the object in the array
js判断对象是否为空
PgSQL learning notes