您的位置:首页 > 编程语言 > Java开发

Java 字节码查看与修改

2014-09-17 08:35 232 查看


JBE - Java Bytecode Editor

JBE is a bytecode editor suitable for viewing and modifying java class files. It is built on top of the open-source jclasslib
bytecode viewer by ej-technologies. For verification and exporting the class files, JBE uses the the Bytecode
Engineering Library by Apache's Jakarta project.

JBE是一个字节码编辑器,适合查看与编辑java class文件。它是et-technologies公司开发的建立在开源的jclasslib bytecode viewer之上的。用来检验和导出字节码class文件的。JBE用Apache公司的Jakarta项目的BytecodeEngineering Library库。

JBE requires Java 1.5 to run.--JBE需要java1.5的环境运行,貌似我的1.7也可以哦!
It uses the standard mnemonics for JVM opcodes as instruction names. Jumps are absolute, labels are shown as line numbers. The cases/targets of tableswitch and lookupswitch instructions should be preceded by a tab or a space.--它用了jvm标准的操作码助记符名称。跳跃是绝对的,标签显示为行号。例如tableswitch和lookupswitch目标指令前面是一个Tab制表符或者一个空格space。
Class names should be written using the Java class file format conventions, so java.lang.String becomes java/lang/String—类名按照java类文件格式惯例,所以java.lang.String类就变成了java/lang/String。
Type information is also written as they appear in class files (e.g. the descriptor I speficies an integer, [Ljava/lang/Thread; is an array of Threads, etc.).-->类型信息按照他们在类文件中样子写出来。例如描述给I变量指定为整型integer,[Ljava/lang/Thread是一个线程的数组等等。
To add a constant, method, interface or field, select the appropriate section in the left pane. A form for adding the appropriate attribute is displayed on the main pane.--> 选择软件左边面板中合适的章节可以添加常量,方法,接口或者字段。主面板显示了添加合适属性的表格。
To remove a constant, method, interface or a field, select it in the left pane. A delete button appears on the main pane.—>选中左边面板中的常量,方接口或者字段,主面板中出现一个删除按钮,可以删除他们。
To add or remove an exception select the method's exception table tab. There, a form is included for adding an exception. An exception can be removed via the delete button.-->想要添加或者移除一个异常,选中方法异常表标签,然后出现一个可以添加异常的表格。一个异常可以通过点击删除按钮的方法移除。
There is no global save, all changes are directly applied to the class file after adding/deleting/modifying attributes. To return to the original file, select the appropariate menu item or button ("Revert to original class file").-->没有全局的保存,在添加/删除/修改属性后,所有的改变直接应用到class文件。选中合适的菜单项或者按钮,
返回原始的文件。

Download: Java Bytecode Editor 0.1.1

Changes from 0.1b:

fix for saving InvokeInterface instruction by Carl Rumachik

下面写一个HelloWorld程序:类文件如下:

public class HelloWorld{
public static void main(String args[]){
System.out.println("hello,world");
}
}


启动cmd命令窗口

可以看到类文件没有错误编译运行通过,下一步我想通过直接修改字节码中的hello,world



打开jbe软件,打开编译出来的class文件



将"hello,world"换成“你好,世界",点击保存(save method)按钮



回到命令行直接运行刚刚的class文件查看输出是否已经如我们所料。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: