
268 Chapter 7 • Securing Your Java Code
c = defineClass(name, classData, 0, classData.length);
if (c==null)
throw new ClassNotFoundException(name);
loadedClasses.put(name, c);
if (resolve) resolveClass(c);
return c;
}
private byte [] loadClassData(String name) {
int byteTemp;
ByteArrayOutputStream out = new ByteArrayOutputStream();
final int EOF = -1;
name = name + ".class"; //creates new string object
try {
FileInputStream fi = new FileInputStream(name);
while((byteTemp = fi.read()) != EOF)
out.write(byteTemp);
} catch (IOException e) {}
return out.toByteArray();
}
}
This program will read the classes from disk (in the current direc-
tory) and load them into the VM. ...