Child-first mod class loading
This commit is contained in:
@@ -75,7 +75,27 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
|
||||
@Override
|
||||
public ClassLoader loadJar(Fi jar, ClassLoader parent) throws Exception{
|
||||
return new DexClassLoader(jar.file().getPath(), getFilesDir().getPath(), null, parent);
|
||||
return new DexClassLoader(jar.file().getPath(), getFilesDir().getPath(), null, parent){
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException{
|
||||
//check for loaded state
|
||||
Class<?> loadedClass = findLoadedClass(name);
|
||||
if(loadedClass == null){
|
||||
try{
|
||||
//try to load own class first
|
||||
loadedClass = findClass(name);
|
||||
}catch(ClassNotFoundException e){
|
||||
//use parent if not found
|
||||
loadedClass = super.loadClass(name, resolve);
|
||||
}
|
||||
}
|
||||
|
||||
if(resolve){
|
||||
resolveClass(loadedClass);
|
||||
}
|
||||
return loadedClass;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user