Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.MethodInsnNode


    il.add(new JumpInsnNode(GOTO, end));
    il.add(label);
    il.add(new FrameNode(F_SAME, 0, null, 0, null));
    il.add(new TypeInsnNode(NEW, "java/lang/IllegalArgumentException"));
    il.add(new InsnNode(DUP));
    il.add(new MethodInsnNode(INVOKESPECIAL,
        "java/lang/IllegalArgumentException", "<init>", "()V"));
    il.add(new InsnNode(ATHROW));
    il.add(end);
    il.add(new FrameNode(F_SAME, 0, null, 0, null));
    il.add(new InsnNode(RETURN));
View Full Code Here


          AbstractInsnNode in = (AbstractInsnNode) j.next();
          int op = in.getOpcode();
          if ((op >= IRETURN && op <= RETURN) || op == ATHROW) {
            InsnList il = new InsnList();
            il.add(new FieldInsnNode(GETSTATIC, cn.name, "timer", "J"));
            il.add(new MethodInsnNode(INVOKESTATIC, "java/lang/System",
                "currentTimeMillis", "()J"));
            il.add(new InsnNode(LADD));
            il.add(new FieldInsnNode(PUTSTATIC, cn.name, "timer", "J"));
            if (in.getPrevious() == null) {
              continue;
            }
            insns.insert(in.getPrevious(), il);
          }
        }
        InsnList il = new InsnList();
        il.add(new FieldInsnNode(GETSTATIC, cn.name, "timer", "J"));
        il.add(new MethodInsnNode(INVOKESTATIC, "java/lang/System",
            "currentTimeMillis", "()J"));
        il.add(new InsnNode(LSUB));
        il.add(new FieldInsnNode(PUTSTATIC, cn.name, "timer", "J"));
        insns.insert(il);
View Full Code Here

      MethodNode mn = new MethodNode(ACC_PUBLIC, "<init>", "()V", null,
          null);
      cn.methods.add(mn);
      InsnList il = mn.instructions;
      il.add(new VarInsnNode(ALOAD, 0));
      il.add(new MethodInsnNode(INVOKESPECIAL, "java/lang/Object",
          "<init>", "()V"));
      il.add(new InsnNode(RETURN));
      mn.maxStack = 1;
      mn.maxLocals = 1;
    }
    {
      MethodNode mn = new MethodNode(ACC_PUBLIC, "getF", "()I", null,
          null);
      cn.methods.add(mn);
      InsnList il = mn.instructions;
      il.add(new VarInsnNode(ALOAD, 0));
      il.add(new FieldInsnNode(GETFIELD, "pkg/Bean", "f", "I"));
      il.add(new InsnNode(IRETURN));
      mn.maxStack = 1;
      mn.maxLocals = 1;
    }
    {
      MethodNode mn = new MethodNode(ACC_PUBLIC, "setF", "(I)V", null,
          null);
      cn.methods.add(mn);
      InsnList il = mn.instructions;
      il.add(new VarInsnNode(ALOAD, 0));
      il.add(new VarInsnNode(ILOAD, 1));
      il.add(new FieldInsnNode(PUTFIELD, "pkg/Bean", "f", "I"));
      il.add(new InsnNode(RETURN));
      mn.maxStack = 2;
      mn.maxLocals = 2;
    }
    MethodNode mn = new MethodNode(ACC_PUBLIC, "checkAndSetF", "(I)V",
        null, null);
    cn.methods.add(mn);
    InsnList il = mn.instructions;
    il.add(new VarInsnNode(ILOAD, 1));
    LabelNode label = new LabelNode();
    il.add(new JumpInsnNode(IFLT, label));
    il.add(new VarInsnNode(ALOAD, 0));
    il.add(new VarInsnNode(ILOAD, 1));
    il.add(new FieldInsnNode(PUTFIELD, "pkg/Bean", "f", "I"));
    LabelNode end = new LabelNode();
    il.add(new JumpInsnNode(GOTO, end));
    il.add(label);
    il.add(new FrameNode(F_SAME, 0, null, 0, null));
    il.add(new TypeInsnNode(NEW, "java/lang/IllegalArgumentException"));
    il.add(new InsnNode(DUP));
    il.add(new MethodInsnNode(INVOKESPECIAL,
        "java/lang/IllegalArgumentException", "<init>", "()V"));
    il.add(new InsnNode(ATHROW));
    il.add(end);
    il.add(new FrameNode(F_SAME, 0, null, 0, null));
    il.add(new InsnNode(RETURN));
View Full Code Here

          }
          il.add(new LookupSwitchInsnNode(getLabel(((IInteger)((IConstructor)v).get(0)).intValue()),
                          ka,
                          la));
        } else if (((IConstructor)v).getName().equals("method")) {
          il.add(new MethodInsnNode(((IInteger)((IConstructor)v).get(0)).intValue(),
                        ((IString)((IConstructor)v).get(1)).getValue(),
                        ((IString)((IConstructor)v).get(2)).getValue(),
                        ((IString)((IConstructor)v).get(3)).getValue()));
        } else if (((IConstructor)v).getName().equals("multiANewArray")) {
          il.add(new MultiANewArrayInsnNode(((IString)((IConstructor)v).get(0)).getValue(),
View Full Code Here

          if (firstCase) { firstCase = false; } else { writer.write(", "); }
          writer.write("" + getLabelIndex(l));
        }
        writer.write("])");
      } else if (ai instanceof MethodInsnNode) {
        MethodInsnNode n = ((MethodInsnNode)ai);
        writer.write("\n\t\t\t\tmethod(" + n.getOpcode() + ", \"" + escape(n.owner) + "\", \"" + escape(n.name) + "\", \"" + escape(n.desc) + "\")");
      } else if (ai instanceof MultiANewArrayInsnNode) {
        MultiANewArrayInsnNode n = ((MultiANewArrayInsnNode)ai);
        writer.write("\n\t\t\t\tmultiANewArray(\"" + escape(n.desc) + "\", " + n.dims + ")");
      } else if (ai instanceof TableSwitchInsnNode) {
        TableSwitchInsnNode n = ((TableSwitchInsnNode)ai);
        writer.write("\n\t\t\t\ttableSwitch(" + n.min + ", " + n.max + ", " + getLabelIndex(n.dflt) + ", [");
        boolean firstCase = true;
        for (LabelNode l : (List<LabelNode>)n.labels) {
          if (firstCase) { firstCase = false; } else { writer.write(", "); }
          writer.write("" + getLabelIndex(l));
        }
        writer.write("])");
      } else if (ai instanceof TypeInsnNode) {
        TypeInsnNode n = ((TypeInsnNode)ai);
        writer.write("\n\t\t\t\t\\type(" + n.getOpcode() + ", \"" + escape(n.desc) + "\")");
      } else {
        if (!(ai instanceof FrameNode)) {
          throw new RuntimeException("Error: Unsupported instruction encountered (" + ai.getClass() + ").");
        }
        first = true;
View Full Code Here

     
      if (PUTFIELD == fn.getOpcode() && components.containsKey(fn.owner)) {
        changed = true;
        i = InstructionMutator.on(instructions, fn)
          .insertAtOffset(0,
            new MethodInsnNode(INVOKEVIRTUAL, fn.owner, fn.name, param(fn)))
          .delete(0)
          .transform();
      } else if (GETFIELD == fn.getOpcode() && components.containsKey(fn.owner)) {
        changed = true;
       
        i = on(instructions, fn)
          .insertAtOffset(0,
            new MethodInsnNode(INVOKEVIRTUAL, fn.owner, fn.name, "()" + fn.desc))
          .delete(0)
          .transform();
      }
    }
   
View Full Code Here

class ByteBufferHelper {
  private final ClassMetadata meta;
 
  AbstractInsnNode invokeGetter(String name) {
    FieldDescriptor fd = find(name);
    return new MethodInsnNode(FieldToStructMethodTransformer.INVOKEVIRTUAL, "java/nio/ByteBuffer", getter(name), "(I)" + castedDesc(fd));
  }
View Full Code Here

 
  AbstractInsnNode invokePutter(String name) {
    FieldDescriptor fd = find(name);
   
    String desc = "(I" + castedDesc(fd) + ")Ljava/nio/ByteBuffer;";
    return new MethodInsnNode(FieldToStructMethodTransformer.INVOKEVIRTUAL, "java/nio/ByteBuffer", putter(name), desc);
  }
View Full Code Here

        {
            AbstractInsnNode node = (AbstractInsnNode) li.next();

            if (node.getOpcode() == INVOKESPECIAL)
            {
                MethodInsnNode mnode = (MethodInsnNode) node;

                assert mnode.owner.equals(classNode.superName);
                assert mnode.name.equals(CONSTRUCTOR_NAME);
                assert mnode.desc.equals(cons.desc);
View Full Code Here

            String methodDescription = opcode == GETFIELD ? "()" + fnode.desc : "(" + fnode.desc + ")V";

            // Replace the field access node with the appropriate method invocation.

            insns.insertBefore(fnode, new MethodInsnNode(INVOKEVIRTUAL, fnode.owner, methodName, methodDescription));

            it.remove();
        }
    }
View Full Code Here

TOP

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

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.