Class 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
Superclass for the INVOKExxx family of instructions.
  • Constructor Details

    • InvokeInstruction

      InvokeInstruction()
      Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
    • 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)
      Gets the name of the referenced class or interface.

      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 - Thrown 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:
    • 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.