Created
December 9, 2020 20:07
-
-
Save destan/8bf1ddbc513dfdde7f14b2391ff3cb45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.objectweb.asm.ClassReader; | |
import org.objectweb.asm.ClassVisitor; | |
import org.objectweb.asm.util.TraceClassVisitor; | |
import java.io.PrintWriter; | |
import java.io.StringWriter; | |
import java.io.Writer; | |
import static org.objectweb.asm.Opcodes.ASM9; | |
/** | |
* Created on December, 2020 | |
* | |
* @author destan | |
*/ | |
public class ByteCodeUtils { | |
private ByteCodeUtils() { | |
} | |
public static String toReadableByteCode(byte[] content) { | |
final Writer writer = new StringWriter(); | |
new ClassReader(content).accept(new VisitAdapter(writer), 0); | |
return writer.toString(); | |
} | |
private static class VisitAdapter extends ClassVisitor { | |
public VisitAdapter(Writer writer) { | |
super(ASM9, new TraceClassVisitor(null, new PrintWriter(writer))); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment