Search in sources :

Example 11 with TraceClassVisitor

use of org.objectweb.asm.util.TraceClassVisitor in project CodeChickenLib by Chicken-Bones.

the class ASMHelper method dump.

public static void dump(Acceptor acceptor, File file, boolean filterImportant, boolean sortLocals, boolean textify) {
    try {
        if (!file.getParentFile().exists())
            file.getParentFile().mkdirs();
        if (!file.exists())
            file.createNewFile();
        PrintWriter pout = new PrintWriter(file);
        ClassVisitor cv = new TraceClassVisitor(null, textify ? new Textifier() : new ASMifier(), pout);
        if (filterImportant)
            cv = new ImportantInsnVisitor(cv);
        if (sortLocals)
            cv = new LocalVariablesSorterVisitor(cv);
        acceptor.accept(cv);
        pout.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ASMifier(org.objectweb.asm.util.ASMifier) TraceClassVisitor(org.objectweb.asm.util.TraceClassVisitor) TraceClassVisitor(org.objectweb.asm.util.TraceClassVisitor) ClassVisitor(org.objectweb.asm.ClassVisitor) IOException(java.io.IOException) Textifier(org.objectweb.asm.util.Textifier) PrintWriter(java.io.PrintWriter)

Example 12 with TraceClassVisitor

use of org.objectweb.asm.util.TraceClassVisitor in project pinpoint by naver.

the class ASMClassWriterTest method accept.

@Test
public void accept() throws Exception {
    final String className = "com.navercorp.pinpoint.profiler.instrument.mock.SampleClass";
    ClassNode classNode = ASMClassNodeLoader.get(JavaAssistUtils.javaNameToJvmName(className));
    ASMClassWriter cw = new ASMClassWriter(pluginContext, 0, null);
    TraceClassVisitor tcv = new TraceClassVisitor(cw, null);
    classNode.accept(tcv);
}
Also used : ClassNode(org.objectweb.asm.tree.ClassNode) TraceClassVisitor(org.objectweb.asm.util.TraceClassVisitor) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 13 with TraceClassVisitor

use of org.objectweb.asm.util.TraceClassVisitor in project bytecode-viewer by Konloch.

the class ASMTextifierDisassembler method decompileClassNode.

@Override
public String decompileClassNode(ClassNode cn, byte[] b) {
    StringWriter writer = new StringWriter();
    cn.accept(new TraceClassVisitor(null, new Textifier(), new PrintWriter(writer)));
    return writer.toString();
}
Also used : TraceClassVisitor(org.objectweb.asm.util.TraceClassVisitor) StringWriter(java.io.StringWriter) Textifier(org.objectweb.asm.util.Textifier) PrintWriter(java.io.PrintWriter)

Example 14 with TraceClassVisitor

use of org.objectweb.asm.util.TraceClassVisitor in project lwjgl by LWJGL.

the class MappedObjectTransformer method printBytecode.

private static void printBytecode(byte[] bytecode) {
    StringWriter sw = new StringWriter();
    ClassVisitor tracer = new TraceClassVisitor(new ClassWriter(0), new PrintWriter(sw));
    new ClassReader(bytecode).accept(tracer, 0);
    String dump = sw.toString();
    LWJGLUtil.log(dump);
}
Also used : TraceClassVisitor(org.objectweb.asm.util.TraceClassVisitor) StringWriter(java.io.StringWriter) TraceClassVisitor(org.objectweb.asm.util.TraceClassVisitor) ClassWriter(org.objectweb.asm.ClassWriter) PrintWriter(java.io.PrintWriter)

Example 15 with TraceClassVisitor

use of org.objectweb.asm.util.TraceClassVisitor in project tomee by apache.

the class Asmifier method write.

public static void write(final ClassReader reader, final OutputStream write) throws IOException {
    final TraceClassVisitor visitor = new TraceClassVisitor(null, new ASMifier(), new PrintWriter(write));
    reader.accept(visitor, ClassReader.SKIP_DEBUG);
    write.close();
}
Also used : ASMifier(org.objectweb.asm.util.ASMifier) TraceClassVisitor(org.objectweb.asm.util.TraceClassVisitor) PrintWriter(java.io.PrintWriter)

Aggregations

TraceClassVisitor (org.objectweb.asm.util.TraceClassVisitor)39 PrintWriter (java.io.PrintWriter)31 ClassReader (org.objectweb.asm.ClassReader)24 ClassWriter (org.objectweb.asm.ClassWriter)16 StringWriter (java.io.StringWriter)14 ClassVisitor (org.objectweb.asm.ClassVisitor)10 Textifier (org.objectweb.asm.util.Textifier)10 IOException (java.io.IOException)6 File (java.io.File)5 ClassNode (org.objectweb.asm.tree.ClassNode)5 ArrayList (java.util.ArrayList)3 ASMifier (org.objectweb.asm.util.ASMifier)3 CheckClassAdapter (org.objectweb.asm.util.CheckClassAdapter)3 NeverNullArgAnalyzerAdapter (edu.columbia.cs.psl.phosphor.instrumenter.analyzer.NeverNullArgAnalyzerAdapter)2 FileInputStream (java.io.FileInputStream)2 URL (java.net.URL)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 DrillConfig (org.apache.drill.common.config.DrillConfig)2 QueryClassLoader (org.apache.drill.exec.compile.QueryClassLoader)2