Search in sources :

Example 1 with DrillCheckClassAdapter

use of org.apache.drill.exec.compile.DrillCheckClassAdapter in project drill by axbaretto.

the class ReplaceMethodInvoke method check.

private static final void check(final byte[] b) {
    final ClassReader cr = new ClassReader(b);
    final ClassWriter cw = writer();
    final ClassVisitor cv = new DrillCheckClassAdapter(cw);
    cr.accept(cv, 0);
    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);
    DrillCheckClassAdapter.verify(new ClassReader(cw.toByteArray()), false, pw);
    final String checkString = sw.toString();
    if (!checkString.isEmpty()) {
        throw new IllegalStateException(checkString);
    }
}
Also used : StringWriter(java.io.StringWriter) ClassReader(org.objectweb.asm.ClassReader) TraceClassVisitor(org.objectweb.asm.util.TraceClassVisitor) ClassVisitor(org.objectweb.asm.ClassVisitor) DrillCheckClassAdapter(org.apache.drill.exec.compile.DrillCheckClassAdapter) ClassWriter(org.objectweb.asm.ClassWriter) PrintWriter(java.io.PrintWriter)

Example 2 with DrillCheckClassAdapter

use of org.apache.drill.exec.compile.DrillCheckClassAdapter in project drill by apache.

the class ReplaceMethodInvoke method check.

private static final void check(final byte[] b) {
    final ClassReader cr = new ClassReader(b);
    final ClassWriter cw = writer();
    final ClassVisitor cv = new DrillCheckClassAdapter(cw);
    cr.accept(cv, 0);
    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);
    DrillCheckClassAdapter.verify(new ClassReader(cw.toByteArray()), false, pw);
    final String checkString = sw.toString();
    if (!checkString.isEmpty()) {
        throw new IllegalStateException(checkString);
    }
}
Also used : StringWriter(java.io.StringWriter) ClassReader(org.objectweb.asm.ClassReader) TraceClassVisitor(org.objectweb.asm.util.TraceClassVisitor) ClassVisitor(org.objectweb.asm.ClassVisitor) DrillCheckClassAdapter(org.apache.drill.exec.compile.DrillCheckClassAdapter) ClassWriter(org.objectweb.asm.ClassWriter) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2 DrillCheckClassAdapter (org.apache.drill.exec.compile.DrillCheckClassAdapter)2 ClassReader (org.objectweb.asm.ClassReader)2 ClassVisitor (org.objectweb.asm.ClassVisitor)2 ClassWriter (org.objectweb.asm.ClassWriter)2 TraceClassVisitor (org.objectweb.asm.util.TraceClassVisitor)2