Class Instruction

java.lang.Object
org.aspectj.apache.bcel.generic.Instruction
All Implemented Interfaces:
Serializable, Cloneable, Constants
Direct Known Subclasses:
InstructionBranch, InstructionByte, InstructionCP, InstructionLV, InstructionShort, RET

public class Instruction extends Object implements Cloneable, Serializable, Constants
Abstract super class for all Java byte codes.
Version:
$Id: Instruction.java,v 1.10 2011/04/05 15:15:33 aclement Exp $
Author:
M. Dahm
See Also:
Serialized Form
  • Field Details

    • opcode

      public short opcode
  • Constructor Details

    • Instruction

      public Instruction(short opcode)
  • Method Details

    • dump

      public void dump(DataOutputStream out) throws IOException
      Throws:
      IOException
    • getName

      public String getName()
    • copy

      public final Instruction copy()
      Use with caution, since 'BranchInstruction's have a 'target' reference which is not copied correctly (only basic types are). This also applies for 'Select' instructions with their multiple branch targets.
      Returns:
      (shallow) copy of an instruction
    • readInstruction

      public static final Instruction readInstruction(ByteSequence bytes) throws IOException
      Read an instruction bytecode from an input stream and return the appropriate object.
      Parameters:
      file - file to read from
      Returns:
      instruction object being read
      Throws:
      IOException
    • consumeStack

      public int consumeStack(ConstantPool cpg)
      Returns:
      Number of words consumed from stack by this instruction, or Constants.UNPREDICTABLE, if this can not be computed statically
    • produceStack

      public int produceStack(ConstantPool cpg)
      Returns:
      Number of words produced onto stack by this instruction, or Constants.UNPREDICTABLE, if this can not be computed statically
    • getOpcode

      public short getOpcode()
    • getLength

      public int getLength()
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getType

      public Type getType()
    • getType

      public Type getType(ConstantPool cp)
    • getValue

      public Number getValue()
    • getIndex

      public int getIndex()
    • setIndex

      public void setIndex(int i)
    • getValue

      public Object getValue(ConstantPool cpg)
    • isLoadInstruction

      public boolean isLoadInstruction()
    • isASTORE

      public boolean isASTORE()
    • isALOAD

      public boolean isALOAD()
    • isStoreInstruction

      public boolean isStoreInstruction()
    • isJsrInstruction

      public boolean isJsrInstruction()
    • isConstantInstruction

      public boolean isConstantInstruction()
    • isConstantPoolInstruction

      public boolean isConstantPoolInstruction()
    • isStackProducer

      public boolean isStackProducer()
    • isStackConsumer

      public boolean isStackConsumer()
    • isIndexedInstruction

      public boolean isIndexedInstruction()
    • isArrayCreationInstruction

      public boolean isArrayCreationInstruction()
    • getLoadClassType

      public ObjectType getLoadClassType(ConstantPool cpg)
    • isReturnInstruction

      public boolean isReturnInstruction()
    • isLocalVariableInstruction

      public boolean isLocalVariableInstruction()
    • toString

      public String toString(boolean verbose)
      Long output format: 'name of opcode' "[" 'opcode number' "]" "(" 'length of instruction' ")"
    • toString

      public String toString()
      Overrides:
      toString in class Object