File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -112,15 +112,15 @@ protected Class<?> loadClass(String name, boolean resolve)
112
112
113
113
双亲委派模型保证了Java程序的稳定运行,可以避免类的重复加载(JVM 区分不同类的方式不仅仅根据类名,相同的类文件被不同的类加载器加载产生的是两个不同的类),也保证了 Java 的核心 API 不被篡改。如果不用没有使用双亲委派模型,而是每个类加载器加载自己的话就会出现一些问题,比如我们编写一个称为 ` java.lang.Object ` 类的话,那么程序运行的时候,系统就会出现多个不同的 ` Object ` 类。
114
114
115
- ### 如果我们不想要双亲委派模型怎么办 ?
115
+ ### 如果我们不想用双亲委派模型怎么办 ?
116
116
117
117
为了避免双亲委托机制,我们可以自己定义一个类加载器,然后重载 ` loadClass() ` 即可。
118
118
119
119
## 自定义类加载器
120
120
121
121
除了 ` BootstrapClassLoader ` 其他类加载器均由 Java 实现且全部继承自` java.lang.ClassLoader ` 。如果我们要自定义自己的类加载器,很明显需要继承 ` ClassLoader ` 。
122
122
123
- ## 推荐
123
+ ## 推荐阅读
124
124
125
125
- < https://blog.csdn.net/xyang81/article/details/7292380 >
126
126
- < https://juejin.im/post/5c04892351882516e70dcc9b >
You can’t perform that action at this time.
0 commit comments