本文共 390 字,大约阅读时间需要 1 分钟。
我们在学习动态代理的实现原理时往往希望能够将字节码文件反编译出来看一下代理类时如何调用handler的invoke方法来实现代理的,但是往往我们不知道如何下载字节码文件,或者下载来不知道下载路径,又或者使用javap反编译出来的结构并不是我们想要的,那么根据一下步骤可以轻松的得到字节码的反编译结果:
- 设置System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");或者在VMoptions中加入参数-Dsun.misc.ProxyGenerator.saveGeneratedFiles=true可以保存生成的动态代理类的class文件,生成的代理class文件在工程根目录的com\sun\proxy中。(JDK1.8)
- 反编译class文件(选择CFR反编译结果更可靠):
转载地址:http://csnqi.baihongyu.com/