-
Notifications
You must be signed in to change notification settings - Fork 45.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
类加载器一问的补充说明Java->JVM->6.类加载器 #871
Comments
不想用双亲委派模型肯定不是覆盖findClass方法呀,覆盖这个方法就等于默认使用双亲委派模型。
在 2020-07-28 16:41:48,"Zerah" <[email protected]> 写道:
如果我们不想用双亲委派模型怎么办?
不想使用双亲委派模型,我们可以自定义自己的类加载器,需要继承 java.lang.ClassLoader,但是如果是要自定类加载器,也是需要继承ClassLoader,但是覆盖的是findClass方法,这点需要做下补充说明,这点看源码就可以确认,可以参考博客:https://blog.csdn.net/SEU_Calvin/article/details/52315125,因为最近面试经常被问到,之前被误导了,面试官反复确认,我还是说是重写`loadClass`方法,因而这点感觉需要做下补充说明。
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
没问题的,就是可能之前我没表述清楚,我想表达的是:之前楼主没有对这个情况做区分说明,感觉容易引起误导(我就是),双亲委派模型->重写loadClass()方法,自定义类加载器->重写findClass()方法应该需要被强调一下。 |
|
biu 特否,我的gay------------------ 原始邮件 ------------------
发件人: "SnailClimb"<[email protected]>
发送时间: 2020年7月31日(星期五) 晚上10:55
收件人: "Snailclimb/JavaGuide"<[email protected]>;
抄送: "Zerah"<[email protected]>;"Author"<[email protected]>;
主题: Re: [Snailclimb/JavaGuide] 类加载器一问的补充说明Java->JVM->6.类加载器 (#871)
|
如果我们不想用双亲委派模型怎么办?
不想使用双亲委派模型,我们可以自定义自己的类加载器,需要继承
java.lang.ClassLoader
,但是如果是要自定类加载器,也是需要继承ClassLoader
,但是覆盖的是findClass方法,这点需要做下补充说明,这点看源码就可以确认,可以参考博客:https://blog.csdn.net/SEU_Calvin/article/details/52315125,因为最近面试经常被问到,之前被误导了,面试官反复确认,我还是说是重写`loadClass`方法,因而这点感觉需要做下补充说明。The text was updated successfully, but these errors were encountered: