主要目标是使用我自己的实现覆盖
Android系统类(Activity,View等).
实现了自定义类加载的ClassLoader,加载非系统类(自定义类)工作.
但是当我尝试使用我的实现加载Activity时 – 它没有加载,因为ClassLoader已经在其缓存中有这个类:
/**
* Returns the class with the specified name if it has already been loaded
* by the virtual machine or {@code null} if it has not yet been loaded.
*
* @param className
* the name of the class to look for.
* @return the {@code Class} object or {@code null} if the requested class
* has not been loaded.
*/
protected final Class> findLoadedClass(String className) {
ClassLoader loader;
if (this == BootClassLoader.getInstance())
loader = null;
else
loader = this;
return VMClassLoader.findLoadedClass(loader, className);
}
如何更改类加载器以注入我自己的类而不是系统?