今天尝试反编译了下使用jdk中的Proxy.newInstance生成的动态代理类的代码。
有点小疑惑请教坛子里的高人。使用jdk中的Proxy.newInstance生成动态代理类仅仅针对接口实现的,一般使用步骤:// 1、定义接口
class interface1{}
class interface2{}
class interface3{}// 2、创建接口的实现类
//对应接口的实现类,被代理的对象
class ImplClass implements interface1,inteface2,interface3{}// 3、创建具体的InvocationHandler
xxxHandler implements InvocationHandler{

private ImplClass implClass;

//注入ImplClass的实例

invoke(0bject Proxy,Method method,Object[] args){
//dosomething
method.inovke(implClass,args);
}
}// 4、根据具体的接口和InvocationHandler生成代理类
ImplClass proxy0 = (ImplClass)Proxy.newInstance(classLoader,interfaces,hanlder);// 5、调用代理的方法
proxy0.doSomething();
查看了下动态生成的proxy0的反编译代码 
具体的doSomething中的方法体//生成的proxy实例继承Proxy并实现被代理的各个接口
class proxy0  extends Proxy implements interface1,inteface2,interface3{
//这个handler引用 4、创建代理时传如handler实例
private InvocationHandler handler

//实现各个interface中的方法
methodXX(object args){
                // 调用传入的handler的invoke方法,传入代理类实例和具体的要调用的被代理方法以及参数
handler.invoke(this,methodXX,args);
}
}
现在我的疑惑是:在InvocationHandler中的invoke方法中为什么需要传入Object proxy呢?
是为了方便调用proxy中的其他方法,还是另有考虑呢?