开发者

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

开发者 https://www.devze.com 2022-12-25 18:46 出处:网络
The answer to \'unloading classes in java\' says - \"The only way that a Class can be unlo开发者_Python百科aded is if the Classloader used is garbage collected.\"

The answer to 'unloading classes in java' says -

"The only way that a Class can be unlo开发者_Python百科aded 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号