Class BranchHandle

java.lang.Object
org.apache.bcel.generic.InstructionHandle
org.apache.bcel.generic.BranchHandle

public final class BranchHandle extends InstructionHandle
BranchHandle is returned by specialized InstructionList.append() whenever a BranchInstruction is appended. This is useful when the target of this instruction is not known at time of creation and must be set later via setTarget().
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getBranchHandle

      static BranchHandle getBranchHandle(BranchInstruction i)
      Factory method.
    • getPosition

      public int getPosition()
      Description copied from class: InstructionHandle
      Gets the position.
      Overrides:
      getPosition in class InstructionHandle
      Returns:
      The position, the byte code offset of the contained instruction. This is accurate only after InstructionList.setPositions() has been called.
    • getTarget

      public InstructionHandle getTarget()
      Gets the target of instruction.
      Returns:
      target of instruction.
    • setInstruction

      public void setInstruction(Instruction i)
      Sets new contents. Old instruction is disposed and may not be used anymore.
      Overrides:
      setInstruction in class InstructionHandle
      Parameters:
      i - The new instruction.
    • setPosition

      void setPosition(int pos)
      Description copied from class: InstructionHandle
      Sets the position, the byte code offset of the contained instruction.
      Overrides:
      setPosition in class InstructionHandle
      Parameters:
      pos - The position.
    • setTarget

      public void setTarget(InstructionHandle ih)
      Pass new target to instruction.
      Parameters:
      ih - The new target.
    • updatePosition

      protected int updatePosition(int offset, int maxOffset)
      Description copied from class: InstructionHandle
      Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable length instructions 'setPositions()' performs multiple passes over the instruction list to calculate the correct (byte) positions and offsets by calling this function.
      Overrides:
      updatePosition in class InstructionHandle
      Parameters:
      offset - additional offset caused by preceding (variable length) instructions.
      maxOffset - The maximum offset that may be caused by these instructions.
      Returns:
      additional offset caused by possible change of this instruction's length.
    • updateTarget

      public void updateTarget(InstructionHandle oldIh, InstructionHandle newIh)
      Update target of instruction.
      Parameters:
      oldIh - The old instruction handle.
      newIh - The new instruction handle.