Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.MethodNode


  MethodVisitor next;

  public RemoveDeadCodeAdapter(String owner, int access, String name,
      String desc, MethodVisitor mv) {
    super(new MethodNode(access, name, desc, null, null));
    this.owner = owner;
    next = mv;
  }
View Full Code Here


    this.owner = owner;
    next = mv;
  }

  public void visitEnd() {
    MethodNode mn = (MethodNode) mv;
    Analyzer a = new Analyzer(new BasicInterpreter());
    try {
      a.analyze(owner, mn);
      Frame[] frames = a.getFrames();
      AbstractInsnNode[] insns = mn.instructions.toArray();
      for (int i = 0; i < frames.length; ++i) {
        if (frames[i] == null && !(insns[i] instanceof LabelNode)) {
          mn.instructions.remove(insns[i]);
        }
      }
    } catch (AnalyzerException ignored) {
    }
    mn.accept(next);
  }
View Full Code Here

  MethodVisitor next;

  public BasicVerifierAdapter(String owner, int access, String name,
      String desc, MethodVisitor mv) {
    super(new MethodNode(access, name, desc, null, null));
    this.owner = owner;
    next = mv;
  }
View Full Code Here

    this.owner = owner;
    next = mv;
  }

  public void visitEnd() {
    MethodNode mn = (MethodNode) mv;
    Analyzer a = new Analyzer(new BasicVerifier());
    try {
      a.analyze(owner, mn);
    } catch (AnalyzerException e) {
      throw new RuntimeException(e.getMessage());
    }
    mn.accept(next);
  }
View Full Code Here

            return null;
        }
        if (methodFilter != null && !(name1 + desc).equals(methodFilter)) {
            return null;
        }
        MethodNode meth = (MethodNode) classNode.visitMethod(
            access, name1, desc, signature, exceptions);
        List text = ((AbstractVisitor) cv).getText();
        int size = text.size();
        MethodVisitor mv = cv.visitMethod(
            access, name1, desc, signature, exceptions);
View Full Code Here

public class RemoveAddZeroTransformerTest extends
    RemoveAddZeroAdapterTest {

  public void test() {
    TraceMethodVisitor tmv = new TraceMethodVisitor(null);
    MethodNode mn = new MethodNode(0, null, null, null, null);
    mn.visitCode();
    mn.visitVarInsn(ILOAD, 1);
    mn.visitInsn(ICONST_0);
    mn.visitInsn(IADD);
    mn.visitInsn(IRETURN);
    mn.visitMaxs(0, 0);
    mn.visitEnd();
    new RemoveAddZeroTransformer(null).transform(mn);
    mn.accept(tmv);
    checkMethod(tmv);
  }
View Full Code Here

public class RemoveLoadStoreTransformerTest extends
    RemoveLoadStoreAdapterTest {

  public void test() {
    TraceMethodVisitor tmv = new TraceMethodVisitor(null);
    MethodNode mn = new MethodNode(0, null, null, null, null);
    mn.visitCode();
    mn.visitVarInsn(ILOAD, 1);
    mn.visitVarInsn(ISTORE, 1);
    mn.visitVarInsn(ILOAD, 1);
    mn.visitInsn(IRETURN);
    mn.visitMaxs(0, 0);
    mn.visitEnd();
    new RemoveLoadStoreTransformer(null).transform(mn);
    mn.accept(tmv);
    checkMethod(tmv);
  }
View Full Code Here

*/
public class OptimizeJumpTransformerTest extends AbstractTestCase {

  public void test() {
    TraceMethodVisitor tmv = new TraceMethodVisitor(null);
    MethodNode mn = new MethodNode(0, null, null, null, null);
    mn.visitCode();
    mn.visitVarInsn(ILOAD, 1);
    Label label = new Label();
    mn.visitJumpInsn(IFLT, label);
    mn.visitVarInsn(ALOAD, 0);
    mn.visitVarInsn(ILOAD, 1);
    mn.visitFieldInsn(PUTFIELD, "pkg/Bean", "f", "I");
    Label end = new Label();
    mn.visitJumpInsn(GOTO, end);
    mn.visitLabel(label);
    mn.visitFrame(F_SAME, 0, null, 0, null);
    mn.visitTypeInsn(NEW, "java/lang/IllegalArgumentException");
    mn.visitInsn(DUP);
    mn.visitMethodInsn(INVOKESPECIAL,
        "java/lang/IllegalArgumentException", "<init>", "()V");
    mn.visitInsn(ATHROW);
    mn.visitLabel(end);
    mn.visitFrame(F_SAME, 0, null, 0, null);
    mn.visitInsn(RETURN);
    mn.visitMaxs(0, 0);
    mn.visitEnd();
    new OptimizeJumpTransformer(null).transform(mn);
    mn.accept(tmv);
    checkMethod(tmv);
  }
View Full Code Here

  public void transform(ClassNode cn) {
    if ((cn.access & ACC_INTERFACE) == 0) {
      boolean isPresent = false;
      Iterator i = cn.methods.iterator();
      while (i.hasNext()) {
        MethodNode mn = (MethodNode) i.next();
        if ("getThis".equals(mn.name)) {
          if ("()Ljava/lang/Object;".equals(mn.desc)) {
            isPresent = true;
            break;
          }
View Full Code Here

public class RemoveGetFieldPutFieldTransformerTest extends
    RemoveGetFieldPutFieldAdapterTest {

  public void test() {
    TraceMethodVisitor tmv = new TraceMethodVisitor(null);
    MethodNode mn = new MethodNode(0, null, null, null, null);
    mn.visitCode();
    mn.visitVarInsn(ALOAD, 0);
    mn.visitVarInsn(ALOAD, 0);
    mn.visitVarInsn(ALOAD, 0);
    mn.visitFieldInsn(GETFIELD, "C", "f", "I");
    mn.visitFieldInsn(PUTFIELD, "C", "f", "I");
    mn.visitFieldInsn(GETFIELD, "C", "f", "I");
    mn.visitInsn(IRETURN);
    mn.visitMaxs(0, 0);
    mn.visitEnd();
    new RemoveGetFieldPutFieldTransformer(null).transform(mn);
    mn.accept(tmv);
    checkMethod(tmv);
  }
View Full Code Here

TOP

Related Classes of org.objectweb.asm.tree.MethodNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.