In a customer class loader, I have a method findClass as follows:
public Class findClass(String className){
byte classByte[];
Class result=null;
result = (Class)classes.get(className);
if(result != null){
return result;
}
try{
return findSystemClass(className);
}catch(Exception e){
}
try{
String classPath =
((String)ClassLoader.getSystemResource(className.replace('.',File.separatorChar)+".class").getFile()).substring(1);
classByte = loadClassData(classPath);
result = defineClass(className,classByte,0,classByte.length,null);
classes.put(className,result);
return result;
}catch(Exception e){
return null;
}
}
How do I specify the name of a class that I’m trying to find if the class is in the default package. For example, if the class is named myclass.class, how do I pass this name to this method. Calling it as findClass("myclass") or findClass("myclass.class")doesn’t seem to work.
Try with fully qualified name:
findClass("mypackage.MyClass")