我的类加载器哪里错了?出现IlleagerAccessError class worker not access its superclass person
import java.lang.reflect.*;
import java.io.*;
class myload extends ClassLoader
{
String path="c:";
myload()
{
super();
}
myload(String path)
{
this.path=path;
}
public Class findClass(String name)throws ClassNotFoundException
{
FileInputStream read=null;
byte[] data=new byte[1024*64];
int number;
try
{
read=new FileInputStream(path+File.separator+name);
number=read.read(data);
return defineClass(data,0,number);
}
catch (Exception e)
{
}
return super.findClass(name);
}
}
class person
{
String name="xxx";
}
//class worker extends person
//{
// String name="yy";
//}
public class hhaha
{
public static void main(String[] args)throws Exception
{
Class one=new myload("d:").loadClass("worker.class");
// one.newInstance();
}
}
|
|