protected Class findClass(String name) throws ClassNotFoundException {
StringBuffer sb = new StringBuffer(name.length()+prefix.length()+6);
sb.append(prefix).append(name.replace('.','/')).append(".class");
InputStream is = getParent().getResourceAsStream(sb.toString());
if (is==null)
throw new ClassNotFoundException(name);
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int len;
while((len=is.read(buf))>=0)
baos.write(buf,0,len);
buf = baos.toByteArray();
int packIndex = name.lastIndexOf('.');
if (packIndex != -1) {
String pkgname = name.substring(0, packIndex);
Package pkg = getPackage(pkgname);
if (pkg == null) {
definePackage(pkgname, null, null, null, null, null, null, null);
}
}
return defineClass(name,buf,0,buf.length);
} catch (IOException e) {
throw new ClassNotFoundException(name,e);
}
}