使用 BCEL 调用方法

发布于 2024-11-06 10:44:11 字数 378 浏览 7 评论 0原文

这个社区中有没有使用过 BCEL 的专家,可以指导我使用 BCEL 调用方法 就像我们使用 java 反射一样。

注意:支持您的回答任何类型的书籍或网络参考都将成为帮助的重要来源。

现在我看到了一个名为 Visitor 的接口,其中包含方法 <强>visitInvokeInstruction() 现在有没有一种方法可以让我调用这些指令(在堆栈上形成一个方法)。

希望这段代码能给大家很多我想要的解释。

提前致谢

is there any expert in this community who have worked with BCEL and can guide me about invocation of method using BCEL just like we use to do with java reflection.

Note:to support your answer any sort of book or web reference will become a great source of help.

Now i have seen a interface named Visitor containing method visitInvokeInstruction()
Now is there a way so that i can invoke these instruction(that formed a method on stack).

Hope this piece of code give u people a lot of explanation what i want.

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一抹淡然 2024-11-13 10:44:11

最好的方法是使用 BCELifier,它是 BCEL 附带的一个类,它接受一个类文件并发出使用 BCEL 发出该类文件的源代码 - 本质上,它不会将类文件反编译为字节码或原始 Java 源代码,而是反编译所需的 BCEL 代码。发出那个。

对于您的情况,只需编写一个简单的虚拟类,其中包含您想要生成的代码,然后运行 ​​BCELifier 并检查结果。

The best way is to use BCELifier, a class that comes with BCEL that takes a classfile and emits source code that uses BCEL to emit that classfile - essentially it decompiles the classfile not into bytecodes or the original Java source, but the BCEL code required to emit that.

In your case, just write a simple, dummy class that contains the code you want to produce, then run BCELifier and check the results.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文