use of org.objectweb.asm.util.Textifier in project groovy by apache.
the class LoggableTextifier method visitAnnotationDefault.
@Override
public Textifier visitAnnotationDefault() {
Textifier t = super.visitAnnotationDefault();
log();
return t;
}
use of org.objectweb.asm.util.Textifier in project bazel by bazelbuild.
the class JavacTurbineTest method textify.
static String textify(byte[] bytes) {
StringWriter sw = new StringWriter();
ClassReader cr = new ClassReader(bytes);
cr.accept(new TraceClassVisitor(null, new Textifier(), new PrintWriter(sw, true)), 0);
return sw.toString();
}
use of org.objectweb.asm.util.Textifier in project elasticsearch by elastic.
the class Debugger method toString.
/** compiles to bytecode, and returns debugging output */
static String toString(Class<?> iface, String source, CompilerSettings settings) {
StringWriter output = new StringWriter();
PrintWriter outputWriter = new PrintWriter(output);
Textifier textifier = new Textifier();
try {
Compiler.compile(iface, "<debugging>", source, settings, textifier);
} catch (Exception e) {
textifier.print(outputWriter);
e.addSuppressed(new Exception("current bytecode: \n" + output));
IOUtils.reThrowUnchecked(e);
throw new AssertionError();
}
textifier.print(outputWriter);
return output.toString();
}
use of org.objectweb.asm.util.Textifier in project Galacticraft by micdoodle8.
the class InsnListSection method toString.
public String toString() {
Textifier t = new Textifier();
accept(new TraceMethodVisitor(t));
StringWriter sw = new StringWriter();
t.print(new PrintWriter(sw));
return sw.toString();
}
use of org.objectweb.asm.util.Textifier in project drill by axbaretto.
the class ReplaceMethodInvoke method main.
// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ReplaceMethodInvoke.class);
public static void main(String[] args) throws Exception {
final String k2 = "org/apache/drill/Pickle.class";
final URL url = Resources.getResource(k2);
final byte[] clazz = Resources.toByteArray(url);
final ClassReader cr = new ClassReader(clazz);
final ClassWriter cw = writer();
final TraceClassVisitor visitor = new TraceClassVisitor(cw, new Textifier(), new PrintWriter(System.out));
final ValueHolderReplacementVisitor v2 = new ValueHolderReplacementVisitor(visitor, true);
// | ClassReader.SKIP_DEBUG);
cr.accept(v2, ClassReader.EXPAND_FRAMES);
final byte[] output = cw.toByteArray();
Files.write(output, new File("/src/scratch/bytes/S.class"));
check(output);
final DrillConfig c = DrillConfig.forClient();
final SystemOptionManager m = new SystemOptionManager(PhysicalPlanReaderTestFactory.defaultLogicalPlanPersistence(c), new LocalPersistentStoreProvider(c), c);
m.init();
try (QueryClassLoader ql = new QueryClassLoader(DrillConfig.create(), m)) {
ql.injectByteCode("org.apache.drill.Pickle$OutgoingBatch", output);
Class<?> clz = ql.loadClass("org.apache.drill.Pickle$OutgoingBatch");
clz.getMethod("x").invoke(null);
}
}
Aggregations