alice.util.AndroidDynamicClassLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tuprolog Show documentation
Show all versions of tuprolog Show documentation
Light-weight Prolog system for Internet applications and infrastructures
The newest version!
package alice.util;
import java.net.URL;
public class AndroidDynamicClassLoader extends AbstractDynamicClassLoader
{
private String dexPath;
private ClassLoader classLoader;
public AndroidDynamicClassLoader()
{
super();
}
public AndroidDynamicClassLoader(URL[] urls)
{
super(urls);
}
public AndroidDynamicClassLoader(URL[] urls, ClassLoader parent)
{
super(urls, parent);
}
private String createPathString()
{
String path;
if(listURLs.isEmpty())
{
path = "";
}
else
{
path = listURLs.get(0).getPath();
for (int i=1; i findClass(String className) throws ClassNotFoundException
{
setDexPath(createPathString());
try {
/**
* More informations on the use of reflection here can be found in the class LibraryManager
* in the method loadLibrary(Strin, String[]).
*/
classLoader = (ClassLoader) Class.forName("dalvik.system.DexClassLoader")
.getConstructor(String.class, String.class, String.class, ClassLoader.class)
.newInstance(dexPath, "/data/data/alice.tuprologx.android/app_dex", null, getParent());
} catch (Exception e) {
throw new ClassNotFoundException(className);
}
return classLoader.loadClass(className);
}
}