Tag: 码字节码操作

ASM:输出java字节码和操作码

我正在尝试编写一个带有.class文件的程序,并收集.class文件的所有方法以及每个方法的内容。 这是我的代码 public class ClassReaderTest1 { public static void main(String[] args) throws Exception{ InputStream in = new FileInputStream(“*.class”); ClassReader reader = new ClassReader(in); ClassNode classNode = new ClassNode(); reader.accept(classNode,0); @SuppressWarnings(“unchecked”) final List methods = classNode.methods; for(MethodNode m: methods){ InsnList inList = m.instructions; System.out.println(m.name); for(int i = 0; i< inList.size(); i++){ System.out.println(" " + Integer.toHexString(inList.get(i).getOpcode())); } […]