FileDocCategorySizeDatePackage
InvokeInstruction.javaAPI DocJava SE 6 API5333Tue Jun 10 00:22:20 BST 2008com.sun.org.apache.bcel.internal.generic

InvokeInstruction

public abstract class InvokeInstruction extends FieldOrMethod implements ExceptionThrower, StackProducer, TypedInstruction, StackConsumer
Super class for the INVOKExxx family of instructions.
version
$Id: InvokeInstruction.java,v 1.1.2.1 2005/07/31 23:44:46 jeffsuttor Exp $
author
M. Dahm

Fields Summary
Constructors Summary
InvokeInstruction()
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction(). Not to be used otherwise.

protected InvokeInstruction(short opcode, int index)

param
index to constant pool

    super(opcode, index);
  
Methods Summary
public intconsumeStack(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen cpg)
Also works for instructions whose stack effect depends on the constant pool entry they reference.

return
Number of words consumed from stack by this instruction

      String signature = getSignature(cpg);
      Type[] args      = Type.getArgumentTypes(signature);
      int    sum;

      if(opcode == Constants.INVOKESTATIC)
	sum = 0;
      else
	sum = 1;  // this reference

      int n = args.length;
      for (int i = 0; i < n; i++)
	sum += args[i].getSize();

      return sum;
   
public com.sun.org.apache.bcel.internal.generic.Type[]getArgumentTypes(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen cpg)

return
argument types of referenced method.

    return Type.getArgumentTypes(getSignature(cpg));
  
public java.lang.StringgetMethodName(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen cpg)

return
name of referenced method.

    return getName(cpg);
  
public com.sun.org.apache.bcel.internal.generic.TypegetReturnType(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen cpg)

return
return type of referenced method.

    return Type.getReturnType(getSignature(cpg));
  
public com.sun.org.apache.bcel.internal.generic.TypegetType(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen cpg)

return
return type of referenced method.

    return getReturnType(cpg);
  
public intproduceStack(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen cpg)
Also works for instructions whose stack effect depends on the constant pool entry they reference.

return
Number of words produced onto stack by this instruction

    return getReturnType(cpg).getSize();
  
public java.lang.StringtoString(com.sun.org.apache.bcel.internal.classfile.ConstantPool cp)

return
mnemonic for instruction with symbolic references resolved

    Constant        c   = cp.getConstant(index);
    StringTokenizer tok = new StringTokenizer(cp.constantToString(c));

    return Constants.OPCODE_NAMES[opcode] + " " +
      tok.nextToken().replace('.", '/") + tok.nextToken();