classloader de 问题

bloodstars 2007-05-13 03:04:36
import java.io.*;
class T
{
public static void main(String ssss[])throws Exception
{
NetworkClassLoader cl=new NetworkClassLoader();
Class c=cl.findClass("d:/A.class");
c.newInstance();
}
}
class NetworkClassLoader extends ClassLoader {
String host;
int port;

public Class findClass(String name){
try{

byte[] b = loadClassData(name);
return defineClass("A", b, 0, b.length);
}
catch(Exception e){System.out.println(e);}
return null;
}

private byte[] loadClassData(String name)throws Exception {
InputStream in=new FileInputStream(name);
byte[] b=new byte[340];
in.read(b);
return b;
}
}
class A
{
A()
{System.out.println("hello world");}
}
A 我已经编译完了
怎么老异常??
Exception in thread "main" java.lang.IllegalAccessException: Class T can not acc
ess a member of class A with modifiers ""
...全文
198 1 打赏 收藏 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
MrJame 2007-05-14
  • 打赏
  • 举报
回复
学习

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧