简体   繁体   English

将类文件(字节)解包到 ASM ClassNode

[英]Unpacking class file (bytes) into ASM ClassNode

Given a class file in the form of an array of bytes, how do you unpack it into an ASM ClassNode with its collection of MethodNodes?给定一个字节数组形式的类文件,你如何将它解压到一个带有 MethodNode 集合的 ASM ClassNode 中? The PDF documentation doesn't seem to say – it seems to assume you will only be doing the reverse, creating a new class – and none of the constructors or methods in the Java doc seem applicable, unless I am missing something? PDF 文档似乎没有说——它似乎假设你只会做相反的事情,创建一个新类——Java 文档中的构造函数或方法似乎都不适用,除非我遗漏了什么?

ClassNode extends ClassVisitor , so you may pass an instance to any method accepting ClassVisitor . ClassNode扩展了ClassVisitor ,因此您可以将实例传递给任何接受ClassVisitor方法。

ClassNode classNode = new ClassNode();
new ClassReader(bytes).accept(classNode, 0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM