use*_*195 8 java reflection android classloader dynamic-class-loaders
主要目标是使用我自己的实现覆盖Android系统类(Activity,View等).
http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html
实现了自定义类加载的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);
}
Run Code Online (Sandbox Code Playgroud)
如何更改类加载器以注入我自己的类而不是系统?
| 归档时间: |
|
| 查看次数: |
1917 次 |
| 最近记录: |