现阶段对ClassLoader的困惑
1.由于CLASSLOADER是DELEGATE模式,加载一个类时总是问一下父CLASSLOADER是否加载了该类,所以你更新了一个CLASS文件时你再加载入来时由于父CLASSLOADER命名空间中已有了该类的,所以不加载新的CLASS。如何加载新的CLASS文件?我找到了一个方法,在工程的CLASSPATH下不要用该类的CLASS文件,定义一个CUSTOM CLASSLOADER,每次加载新的CLASS时都新建一个CUSTOM CLASSLOADER以避免相同命名空间下重复导致不加载新的CLASS文件。这样的做法是把一个CLASS放到了不同的CLASSLOADER命名空间去了,太多重复了,会导致内存不足。有啥方法呢?接着就有下疑点:
?
2.线程的CONTEXT能打破DELEGATE,具体来说没实践过,资料上也说得模糊。
?
?
《inside the jvm》的一些语录:
Once a Java virtual machine has loaded a class named Volcano into aparticular name-space, for example, it is impossible to load a different class namedVolcano into that same name-space;
?
?
Although you can grantspecial access privileges between types belonging to the same package by giving members protected orpackage access, this special access is granted to members of the same package at runtime only if they wereloaded by the same class loader.
?
?
?