package com.aventurine.loader;
import java.util.HashMap;
public class NativeClassLoader extends ClassLoader
{
private static final boolean NativeLoadExternal = true;
private HashMap<String, Class> Classes = null;
private ClassLoader Parent = null;
public static ClassLoader Instance = NativeClassLoader.class.getClassLoader();
private static Class HashMapClass = null;
public NativeClassLoader(ClassLoader aParent) { super(aParent);
System.loadLibrary("SFMiddleWare");
Instance = this;
this.Parent = aParent; }
private static native byte[] loadClassBytes(String paramString);
public NativeClassLoader()
{
this(NativeClassLoader.class.getClassLoader());
}
private Class<?> loadClassNative(String Name) {
byte[] ClassData = loadClassBytes(Name);
Class C = null;
if (ClassData != null)
C = defineClass(Name, ClassData, 0, ClassData.length);
return C;
}
protected synchronized Class<?> loadClass(String name, boolean Resolve)
throws ClassNotFoundException
{
Class C = null;
if (this.Classes != null)
C = (Class)this.Classes.get(name);
if (C == null) {
C = loadClassNative(name);
if (this.Classes == null)
this.Classes = new HashMap();
this.Classes.put(name, C);
}
if (C == null) {
C = this.Parent.loadClass(name);
if (this.Classes == null)
this.Classes = new HashMap();
this.Classes.put(name, C);
}
if (C == null) {
throw new ClassNotFoundException();
}
if (Resolve) {
resolveClass(C);
}
return C;
}
}