use of org.objectweb.asm.util.TraceClassVisitor in project pinpoint by naver.
the class ASMBytecodeDisassembler method accept.
private void accept(byte[] bytecode, Printer printer, PrintWriter writer) {
final ClassReader cr = new ClassReader(bytecode);
final ClassWriter cw = new ClassWriter(this.cwFlag);
final TraceClassVisitor tcv = new TraceClassVisitor(cw, printer, writer);
cr.accept(tcv, this.crFlag);
}
use of org.objectweb.asm.util.TraceClassVisitor in project btrace by btraceio.
the class InstrumentorTestBase method asmify.
protected String asmify(byte[] bytecode) {
StringWriter sw = new StringWriter();
TraceClassVisitor acv = new TraceClassVisitor(new PrintWriter(sw));
new org.objectweb.asm.ClassReader(bytecode).accept(acv, 0);
return sw.toString();
}
use of org.objectweb.asm.util.TraceClassVisitor in project qi4j-sdk by Qi4j.
the class ASMTest method fragmentClassLoaderGenerateClassTest.
@Test
@Ignore("This was dead commented code, ~70% of this source file ... What should we do about this!?!")
public void fragmentClassLoaderGenerateClassTest() throws Exception {
byte[] asm = generateClass();
byte[] cl = FragmentClassLoader.generateClass(QI256Test.TestTransient.TestTransientMixin.class.getName() + "_Stub", QI256Test.TestTransient.TestTransientMixin.class);
new ClassReader(cl).accept(new TraceClassVisitor(new PrintWriter(System.out, true)), 0);
Assert.assertArrayEquals(asm, cl);
}
use of org.objectweb.asm.util.TraceClassVisitor in project LogisticsPipes by RS485.
the class ASMHelper method getContentForMethod.
public static String getContentForMethod(ClassReader classReader, String methodName, String desc, boolean newLine) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
TraceClassVisitor traceClassVisitor = new TraceClassVisitor(null, new MethodTextifier(), printWriter);
FilterClassVisitor myClassVisitor = new FilterClassVisitor(traceClassVisitor, methodName, desc);
classReader.accept(myClassVisitor, ClassReader.SKIP_DEBUG);
BufferedReader reader = new BufferedReader(new StringReader(stringWriter.toString()));
StringBuilder builder = new StringBuilder();
String line;
try {
while ((line = reader.readLine()) != null) {
line = line.trim();
String oldLine = line;
line += " ";
while (!oldLine.equals(line)) {
oldLine = line;
line = line.trim();
line = line.replace("\t", " ");
line = line.replace(" ", " ");
}
builder.append(" ");
builder.append(line);
if (newLine) {
builder.append(System.lineSeparator());
}
}
} catch (IOException e) {
e.printStackTrace();
}
return builder.toString();
}
Aggregations