# Class InvokeInstruction

java.lang.Object
org.apache.bcel.generic.Instruction
org.apache.bcel.generic.CPInstruction
org.apache.bcel.generic.FieldOrMethod
org.apache.bcel.generic.InvokeInstruction

All Implemented Interfaces:
  `Cloneable, ExceptionThrower, IndexedInstruction, LoadClass, StackConsumer, StackProducer, TypedInstruction`

Direct Known Subclasses:
  `INVOKEDYNAMIC, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL`

public abstract class InvokeInstruction extends FieldOrMethod implements ExceptionThrower, StackConsumer, StackProducer
Super class for the INVOKExxx family of instructions.

- ## Field Summary

  ### Fields inherited from class CPInstruction

  `index`

  ### Fields inherited from class Instruction

  `length, opcode`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `InvokeInstruction(short opcode, int index)`
  Constructs an InvokeInstruction.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `consumeStack(ConstantPoolGen cpg)`
  Also works for instructions whose stack effect depends on the constant pool entry they reference.
  `Type[]`
  `getArgumentTypes(ConstantPoolGen cpg)`
  Gets the argument types of referenced method.
  `String`
  `getClassName(ConstantPoolGen cpg)`
  This overrides the deprecated version as we know here that the referenced class may legally be an array.
  `String`
  `getMethodName(ConstantPoolGen cpg)`
  Gets the name of referenced method.
  `Type`
  `getReturnType(ConstantPoolGen cpg)`
  Gets the return type of referenced method.
  `Type`
  `getType(ConstantPoolGen cpg)`
  Gets the return type of referenced method.
  `int`
  `produceStack(ConstantPoolGen cpg)`
  Also works for instructions whose stack effect depends on the constant pool entry they reference.
  `String`
  `toString(ConstantPool cp)`
  Gets the mnemonic for instruction with symbolic references resolved.

  ### Methods inherited from class FieldOrMethod

  `getClassType, getLoadClassType, getName, getReferenceType, getSignature`

  ### Methods inherited from class CPInstruction

  `dump, getIndex, initFromFile, setIndex, toString`

  ### Methods inherited from class Instruction

  `accept, copy, equals, getComparator, getLength, getName, getOpcode, hashCode, isValidByte, isValidShort, readInstruction, setComparator, toString`

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface ExceptionThrower

  `getExceptions`

- ## Constructor Details

  - ### InvokeInstruction

    protected InvokeInstruction(short opcode, int index)
    Constructs an InvokeInstruction.
    Parameters:
      `opcode` - the opcode.
      `index` - to constant pool.

- ## Method Details

  - ### consumeStack

    public int consumeStack(ConstantPoolGen cpg)
    Also works for instructions whose stack effect depends on the constant pool entry they reference.
    Specified by:
      `consumeStack` in interface `StackConsumer`
    Overrides:
      `consumeStack` in class `Instruction`
    Parameters:
      `cpg` - the constant pool generator.
    Returns:
      Number of words consumed from stack by this instruction.

  - ### getArgumentTypes

    public Type[] getArgumentTypes(ConstantPoolGen cpg)
    Gets the argument types of referenced method.
    Parameters:
      `cpg` - the constant pool generator.
    Returns:
      argument types of referenced method.

  - ### getClassName

    public String getClassName(ConstantPoolGen cpg)
    This overrides the deprecated version as we know here that the referenced class may legally be an array.
    Overrides:
      `getClassName` in class `FieldOrMethod`
    Parameters:
      `cpg` - the constant pool generator.
    Returns:
      name of the referenced class/interface.
    Throws:
      `IllegalArgumentException` - if the referenced class is an array (this should not happen)

  - ### getMethodName

    public String getMethodName(ConstantPoolGen cpg)
    Gets the name of referenced method.
    Parameters:
      `cpg` - the constant pool generator.
    Returns:
      name of referenced method.

  - ### getReturnType

    public Type getReturnType(ConstantPoolGen cpg)
    Gets the return type of referenced method.
    Parameters:
      `cpg` - the constant pool generator.
    Returns:
      return type of referenced method.

  - ### getType

    public Type getType(ConstantPoolGen cpg)
    Gets the return type of referenced method.
    Specified by:
      `getType` in interface `LoadClass`
    Specified by:
      `getType` in interface `TypedInstruction`
    Overrides:
      `getType` in class `CPInstruction`
    Parameters:
      `cpg` - the constant pool generator.
    Returns:
      return type of referenced method.
    See Also:
      - `LoadClass.getLoadClassType(ConstantPoolGen)`

  - ### produceStack

    public int produceStack(ConstantPoolGen cpg)
    Also works for instructions whose stack effect depends on the constant pool entry they reference.
    Specified by:
      `produceStack` in interface `StackProducer`
    Overrides:
      `produceStack` in class `Instruction`
    Parameters:
      `cpg` - the constant pool generator.
    Returns:
      Number of words produced onto stack by this instruction.

  - ### toString

    public String toString(ConstantPool cp)
    Description copied from class: `Instruction`
    Gets the mnemonic for instruction with symbolic references resolved.
    Overrides:
      `toString` in class `CPInstruction`
    Parameters:
      `cp` - the constant pool.
    Returns:
      mnemonic for instruction with symbolic references resolved.