这个是老师的例题,第一个程序存储文件名ClassLoaderAttachment.java,第二个MyClassLoader.java第三个文件名ClassLoaderTest.java, 这个是老师的例题,可我按顺序运行,吧加密的ClassLoaderAttachment.class放到指定的目录下后,并删除原来的ClassLoaderAttachment.class,运行ClassLoaderTest就是报错, java.lang.IllegalAccessException: Class df.ClassLoaderTest can not access a member of class df.ClassLoaderAttachment with modifiers ""
请问哪里出了问题??作者: 高鑫 时间: 2012-8-10 22:45
?????作者: 杨文宇 时间: 2012-8-11 00:45
java.lang.IllegalAccessException: Class df.ClassLoaderTest can not access a member of class df.ClassLoaderAttachment with modifiers ""
类加载器不能加载非public 的类。
所以加上public 再试试:
public class ClassLoaderAttachment extends Date{
public String toString(){
return "Hello, world!";
}
}