Java 类org.objectweb.asm.util.CheckMethodAdapter 实例源码

项目:elasticsearch_my    文件:SimpleChecksAdapter.java   
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    MethodVisitor in = cv.visitMethod(access, name, desc, signature, exceptions);
    CheckMethodAdapter checker = new CheckMethodAdapter(WriterConstants.ASM_VERSION, in, new HashMap<Label, Integer>()) {
        @Override
        public void visitJumpInsn(int opcode, Label label) {
            mv.visitJumpInsn(opcode, label);
        }

        @Override
        public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
            mv.visitTryCatchBlock(start, end, handler, type);
        }
    };
    checker.version = WriterConstants.CLASS_VERSION;
    return checker;
}
项目:grappa    文件:AsmTestUtils.java   
public static void assertTraceDumpEquality(
    final MethodNode method, final String traceDump) throws Exception {
    Preconditions.checkNotNull(method, "method");
    final Printer printer = new NonMaxTextifier();
    final TraceMethodVisitor traceMethodVisitor = new TraceMethodVisitor(printer);
    // MethodAdapter checkMethodAdapter = new MethodAdapter(traceMethodVisitor);
    final MethodVisitor checkMethodAdapter = new CheckMethodAdapter(traceMethodVisitor);
    method.accept(checkMethodAdapter);
    final StringWriter stringWriter = new StringWriter();
    final PrintWriter printWriter = new PrintWriter(stringWriter);
    printer.print(printWriter);
    printWriter.flush();

    assertEquals(stringWriter.toString(), traceDump);
}