在我的项目包之外的类上使用asm(java字节码)类读取器?
我通过输入获取类的路径(假设为“C:\Temp\Test.class”)。我想做的是将 ClassReader 初始化到此类,并使用 ClassAdapter 和 ClassWriter 开始对其进行检测( i 我不知道如何
将该类“感染”到类阅读器中?
我尝试使用构造函数 ClassReader(String) 但徒劳无功,
谢谢!
I'm getting by input the path of a class (lets say "C:\Temp\Test.class). What i'd like to do is to intialize a ClassReader to this class and start instrumentation it using ClassAdapter and ClassWriter ( i know how to do the instrumentation).
What I dont know- is how do I "fecth" that class into class reader?
I tried using the constructor ClassReader(String) but it was in vain
thanks ! (and sorry for my bad english)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道您正在使用的库 - 显然它是 ASM。无论如何,我看到 您尝试使用的构造函数不采用文件名,而是采用类的完全限定名称。但是,有 另一个采用 InputStream 的构造函数。因此,您必须能够通过 FileInputStream< 解决问题/a> 到这个构造函数:
I don't know the library you're using — apparently it's ASM. Anyway I see that the constructor you're trying to use does not take a file name, but the fully qualified name of a class. However, there's another constructor that takes an InputStream. So you must be able to solve your problem passing a FileInputStream to this constructor: