ASMfier工具使用

ASMfier完成类似TraceClassVisitor的功能,可以直接打印出asm的字节码。使用方法如下

java -cp E:\study\asm\asm-4.0\lib\asm-4.0.jar;E:\study\asm\asm-4.0\lib\asm-util-4.0.jar org.objectweb.asm.util.ASMifier  java.lang.Runnable

添加asm的两个jar包,asm-4.0.jar和asm-util-4.0.jar,然后运行存在的类文件,就会输出结果!

结果如图:

package asm.java.lang;
import java.util.*;
import org.objectweb.asm.*;
import org.objectweb.asm.attrs.*;
public class RunnableDump implements Opcodes {

public static byte[] dump () throws Exception {

ClassWriter cw = new ClassWriter(0);
FieldVisitor fv;
MethodVisitor mv;
AnnotationVisitor av0;

cw.visit(V1_5, ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE, "java/lang/Runnable",
null, "java/lang/Object", null);

{
mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "run", "()V", null, null);
mv.visitEnd();
}
cw.visitEnd();

return cw.toByteArray();
}
}


你可能感兴趣的:(exception,null,import,工具,byte,interface)