如何重新组合javap生成的java字节码? [英] How can I reassemble java bytecode generated by javap?

查看:168
本文介绍了如何重新组合javap生成的java字节码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够编辑字节码并重新编译成可执行的类文件。我不知道该怎么做。我尝试用javap -c和-v反编译,编辑一些东西,然后将其改回我的类文件,但是我收到错误错误:无法找到或加载主类Test.class。我还想从字节码生成java源代码。有帮助吗?我想在不使用外部程序的情况下自己做。如果可能的话,我想自己做。

I want to be able to edit bytecode and recompile into executable class files. I have no idea how to do this. I have tried decompiling with javap -c and -v, edit something, and change it back to my Class file, but I get an error "Error: Could not find or load main class Test.class". I would also like to generate java source from the bytecode. Any help? I want to do this myself without the use of outside programs. I want to do it myself if at all possible.

推荐答案

javap的输出不适合汇编程序。如果要反汇编和重新组合Java字节码,则需要执行以下操作之一:

The output from javap is not suitable input for an assembler. If you want to disassemble and reassemble Java bytecode, you will need to do one of the following:


  1. 使用第三方工具和第三方工具-party汇编程序格式。

  2. 编写自己的工具(dis)汇编第三方汇编程序格式。

  3. 编写自己的工具,使用你的自己的汇编程序格式。

我会看看烟灰色 Krakatau ,两者都已满( dis)组装能力。 Soot支持少量字节码的中间表示。我相信,Krakatau使用基于流行的Jasmin的表示(尽管该工具本身是用Python编写的)。

I would take a look at Soot and Krakatau, both of which have full (dis)assembling capabilities. Soot supports a handful of intermediate representations for bytecode. Krakatau, I believe, uses a representation based on the popular Jasmin (though the tool itself is written in Python).

这篇关于如何重新组合javap生成的java字节码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆