The JDK comes with 爪哇 which is a tool to disassemble the byte code inside a class file. Editing on byte code level is possible. Have a look at BCEL, a java library designed to read, manipulate and write class files.

Java-net上可以找到编辑字节代码的工具和库的列表。例如 JBE,一个 Java 字节码编辑器,甚至附带一个 GUI。

是的。可以使用 JDK 附带的 javap命令查看类的字节码。例如:

javap -c com.mypackage.MyClass

有几个库和工具可以帮助您处理 Java 字节码,例如 ASM茉莉

根据我的经验,Jclasslib是最好的字节码查看器之一。

至于编辑器,有两种类型: 字节码操作库和具有 GUI 的编辑器。这个问题已经被问过几次了,你可以查看答案和提供的链接。

Just be careful that editing bytecode in not as straightforward as you think. The JVMS imposes many restrictions on how class files should be, and there is a great chance that one of your edit will violate one of them.

检查其他问题:

Editing a .class file directly, playing around with opcodes

是否可以查看类文件的字节码?

Java 字节码编程

查看字节码

忘记 javap 吧! 我使用过的最好的插件是 “用于 Eclipse 的 ASM-字节码大纲插件”

http://asm.ow2.org/eclipse/index.html

It is from ASM (a bytecode manipulation framework).

它显示了字节码(您要求的)、堆栈元素(jvm 样式) ,以及如何使用 asm 框架方法生成相同的结果(生成相同的字节码)。

更好的是,当您选择了源代码时,它可以这样做。 您不必在 bin 目录中找到. class 文件来检查它的字节码。

编辑它们

使用代码:

  • 以访客为基础,非常,非常快。
  • BCEL: 加载字节码作为类文件的内存描述。
  • Javassit: 最简单的一个,可以做模式匹配和表达式替换。

手写: JBE

尝试使用-dirtyJOE-Java 总体编辑器是一个用于编译 Java 二进制文件(. class 文件)的复杂编辑器和查看器。