Why can a class not be unloaded without unloading the classloader?

一笑奈何 提交于 2019-12-23 10:06:30

问题


The answer to 'unloading classes in java' says -

"The only way that a Class can be unloaded is if the Classloader used is garbage collected." I took a look at the JLS but couldn't understand it

Why is this the case?


回答1:


A class is only unloaded when it is garbage collected, and for that to happen there must be no references to it anywhere. And the classloader keeps a reference to each class it loads.



来源:https://stackoverflow.com/questions/2551276/why-can-a-class-not-be-unloaded-without-unloading-the-classloader

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!