Class GotoInstruction


  • public class GotoInstruction
    extends Instruction
    Represents the JVM GOTO and GOTO_W instructions.
    • Constructor Detail

      • GotoInstruction

        public GotoInstruction​(int opcode,
                               int offset,
                               int branchOffset)
        Constructs a GotoInstruction.
        Parameters:
        opcode - The opcode of the instruction.
        offset - The bytecode offset of the instruction.
        branchOffset - The branch target offset relative to current instruction.
        Throws:
        IllegalArgumentException - if the opcode is not GOTO or GOTO_W
      • GotoInstruction

        public GotoInstruction​(int opcode,
                               int offset,
                               short branchOffset)
        Constructs a GotoInstruction.
        Parameters:
        opcode - The opcode of the instruction.
        offset - The bytecode offset of the instruction.
        branchOffset - The branch target offset relative to current instruction.
    • Method Detail

      • write

        public void write​(DataOutputStream dos)
                   throws IOException
        Writes the GOTO opcode and its operands to the DataOutputStream.
        Specified by:
        write in class Instruction
        Parameters:
        dos - The DataOutputStream to write to.
        Throws:
        IOException - If an I/O error occurs.
      • getStackChange

        public int getStackChange()
        Returns the change in stack size caused by this instruction.
        Specified by:
        getStackChange in class Instruction
        Returns:
        The stack size change (none).
      • getLocalChange

        public int getLocalChange()
        Returns the change in local variables caused by this instruction.
        Specified by:
        getLocalChange in class Instruction
        Returns:
        The local variables size change (none).
      • getBranchOffset

        public short getBranchOffset()
        Returns the branch offset.
        Returns:
        The branch target offset.
      • getBranchOffsetWide

        public int getBranchOffsetWide()
        Returns the wide branch offset.
        Returns:
        The wide branch target offset.
      • toString

        public String toString()
        Returns a string representation of the instruction.
        Overrides:
        toString in class Instruction
        Returns:
        The mnemonic and branch target of the instruction.