Comments (1)
如果没有使用双亲委派模型,而是每个类加载器加载自己的话就会出现一些问题,比如我们编写一个称为 java.lang.Object 类的话,那么程序运行的时候,系统就会出现两个不同的 Object 类。双亲委派模型可以保证加载的是 JRE 里的那个 Object 类,而不是你写的 Object 类。这是因为 AppClassLoader 在加载你的 Object 类时,会委托给 ExtClassLoader 去加载,而 ExtClassLoader 又会委托给 BootstrapClassLoader,BootstrapClassLoader 发现自己已经加载过了 Object 类,会直接返回,不会去加载你写的 Object 类。
类名为java开头的会在preDefineClass校验就抛出异常,保护核心类库可能跟这个校验关系更大。而且Classloader还将defineClass定义成了final,这个校验preDefineClass和defineClass相关的本地方法还是private,因此根本无法通过打破双亲委派去定义java.lang.Object或者java.lang.String等。
嗯嗯,有道理,请问可以提交一个PR完善一下我的表达么?
from javaguide.
Related Issues (20)
- SQL语句中having的执行顺序是在select之前吧 HOT 2
- jdk1.7起,静态变量是位于堆区,而不是方法区
- 内容不严谨,复杂度错误 HOT 1
- SPI机制的设计思路和使用场景没有讲到核心
- 网站已经很久没有从此仓库更新 HOT 2
- HashMap 和 Hashtable 的区别补充 HOT 1
- 不推荐使用外键与级联原因的理解(对作者看法的其他意见) HOT 2
- 文章中一个无效的SQL举例 HOT 1
- 一个小的代码块语法格式笔误 HOT 1
- sql面试题中的一个错误答案 HOT 2
- sql面试题中一个作者想表达意思的疑惑 HOT 2
- 集合-常见面试题下-HashMap 的长度为什么是 2 的幂次方这里逻辑不好 HOT 1
- 支持夜间模式 HOT 1
- 希望添加spring cloud更多组件的原理和使用介绍 HOT 1
- 布隆过滤器中哈希计算导致的位图越界溢出问题 HOT 1
- SHH typo HOT 1
- 计算机网络常见面试题总结(上)HTTP Header中常见的字段有误? HOT 1
- Java基础常见面试题总结(中)的字符串拼接这里是不是漏了一部分代码?? HOT 3
- 【Redis为什么用跳表实现有序集合】章节元素查询步骤是否有多余
- 关于 JavaGuide 中接口与抽象类中默认方法的对比的修正 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javaguide.