[英]Why Java Classloader does not release jars
I need to load classes from jars, to do it I'm using:我需要从 jars 加载类,我正在使用:
cls = Class.forName(className, false, classLoader);
At the end, I want to delete these jars, but it seems that this is not possible because ClassLoader does not release the jars.最后想把这些jars删掉,但是好像这个不行,因为ClassLoader没有释放jars。 So I used:所以我用:
classLoader.release();
System.gc();
But unfortunately this does not solve the problem...但不幸的是,这并不能解决问题......
According to the JLS , classes (and therefore JAR-files) cannot be unloaded explicitly. 根据 JLS ,类(以及 JAR 文件)不能显式卸载。
It might be possible to achieve something similar with some trickery as described here , but it depends on the actual implementation of the JVM and is therefore nothing you should build on.可能可以通过此处所述的一些技巧来实现类似的效果,但这取决于 JVM 的实际实现,因此您不应该在此基础上进行构建。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.