package ProjectTests; import java.lang.*; import java.util.*; import java.io.*; public class ADBVClassLoader extends ClassLoader { Hashtable cache = new Hashtable(); /** * ADBVClassLoader.loadClass method comment. */ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { Class c = (Class) cache.get(name); byte data[]; if (c == null) { try { data = loadClassData(name); } catch (ClassNotFoundException e) { throw e; return null; } catch (IOException e) { throw new ClassNotFoundException(); return null; } c = defineClass(data, 0, data.length); if (c == null) return null; cache.put(name, c); } if (resolve) resolveClass(c); return c; } /** * This method was created by a SmartGuide. * @return byte[] * @param name java.lang.String */ private byte loadClassData(String name)[] throws ClassNotFoundException, IOException { byte[] inData = new byte[2000]; FileInputStream in; try { in = new FileInputStream(name); } catch (FileNotFoundException e) { System.out.print("Exception finding file "); System.out.println(name); e.printStackTrace(); throw new ClassNotFoundException(); return null; } try { if (in.read(inData) == 2000) { System.out.print("Whilst reading from file \'"); System.out.print(name); System.out.println("\', the end of the buffer was reached"); } } catch (IOException e) { System.out.print("Exception reading from file "); System.out.println(name); e.printStackTrace(); throw e; return null; } return inData; } }