问题是因为 我创建了代理对象,但是运行代理对象的方法的时候,目标对象的方法没有执行,所以想看下Proxy0.class代码 我在target目录下找不到生成的Proxy0.class文件 ,我想反编译看下(我的机器是MAC)
它并没有存在于本地磁盘。而是在内存中动态加载的一个类。如果要持久化到本地磁盘来看的话
用下面这段代码
byte[] proxyClass = ProxyGenerator.generateProxyClass(proxy.getClass()
.getSimpleName(), proxy.getClass().getInterfaces());
//将字节码文件保存到D盘,文件名为$Proxy0.class
FileOutputStream outputStream = new FileOutputStream(new File(
"d:\\$Proxy0.class"));
outputStream.write(proxyClass);
outputStream.flush();
outputStream.close();
最佳答案 2019-12-24 16:36
它并没有存在于本地磁盘。而是在内存中动态加载的一个类。如果要持久化到本地磁盘来看的话
用下面这段代码
byte[] proxyClass = ProxyGenerator.generateProxyClass(proxy.getClass()
.getSimpleName(), proxy.getClass().getInterfaces());
//将字节码文件保存到D盘,文件名为$Proxy0.class
FileOutputStream outputStream = new FileOutputStream(new File(
"d:\\$Proxy0.class"));
outputStream.write(proxyClass);
outputStream.flush();
outputStream.close();