假如在ClassLoader中做如下的修改:[code]
public class ClassLoader{
private List<ClassLoader> subClassLoaderList = new ArrayList<ClassLoader>();//新增成员
//新增方法
//注册一个ClassLoader
public void registSubClassLoader(ClassLoader loader){
subClassLoaderList.add(loader);
}
//修改方法的实现
public Class<?> findClass(String className)throws ClassNotFoundException{
try{
return findClass(className,false);
}catch(ClassNotFoundException e){
for(ClassLoader cl : subClassLoaderList){
try{
return cl.findClass(className,false);
}catch(ClassNotFoundException e){
}
}
}
throw new ClassNotFoundException(className);
}
}[/code]
会有什么事情发生?
public class ClassLoader{
private List<ClassLoader> subClassLoaderList = new ArrayList<ClassLoader>();//新增成员
//新增方法
//注册一个ClassLoader
public void registSubClassLoader(ClassLoader loader){
subClassLoaderList.add(loader);
}
//修改方法的实现
public Class<?> findClass(String className)throws ClassNotFoundException{
try{
return findClass(className,false);
}catch(ClassNotFoundException e){
for(ClassLoader cl : subClassLoaderList){
try{
return cl.findClass(className,false);
}catch(ClassNotFoundException e){
}
}
}
throw new ClassNotFoundException(className);
}
}[/code]
会有什么事情发生?