0N/Aimport java.io.ByteArrayInputStream;
1785N/Aimport java.io.FileInputStream;
0N/Apublic class Loader2 extends ClassLoader {
0N/A int _recur;
0N/A public void print( String msg ) {
0N/A for( int i=0; i<_recur; i++ )
0N/A System.out.print(" ");
0N/A System.out.println(">>Loader2>> "+msg);
0N/A }
0N/A
0N/A protected Class findClass2(String name) throws ClassNotFoundException {
0N/A print("Fetching the implementation of "+name);
0N/A int old = _recur;
0N/A try {
0N/A FileInputStream fi = new FileInputStream(name+".impl2");
0N/A byte result[] = new byte[fi.available()];
0N/A fi.read(result);
0N/A
1472N/A print("DefineClass1 on "+name);
1472N/A _recur++;
1472N/A Class clazz = defineClass(name, result, 0, result.length);
0N/A _recur = old;
0N/A print("Returning newly loaded class.");
0N/A return clazz;
1320N/A } catch (Exception e) {
1320N/A _recur = old;
1879N/A print("Not found on disk.");
1879N/A // If we caught an exception, either the class was not found or
1879N/A // it was unreadable by our process.
1879N/A return null;
1879N/A //throw new ClassNotFoundException(e.toString());
1879N/A }
1879N/A }
1879N/A
1879N/A protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
1879N/A // Attempt a disk load first
1879N/A Class c = findClass2(name);
1879N/A if( c == null ) {
1879N/A // check if the class has already been loaded
1879N/A print("Checking for prior loaded class "+name);
1879N/A c = findLoadedClass(name);
1879N/A print("Letting super-loader load "+name);
1879N/A int old = _recur;
1879N/A _recur++;
1879N/A c = super.loadClass(name, false);
1879N/A _recur=old;
1879N/A }
1879N/A if (resolve) { print("Resolving class "+name); resolveClass(c); }
1879N/A print("Returning clazz "+c.getClassLoader()+":"+name);
1879N/A return c;
1879N/A }
1879N/A}
1879N/A