Package org.apache.bcel.generic
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:
InstructionHandle,Instruction,InstructionList
-
-
Field Summary
Fields Modifier and Type Field Description private BranchInstructionbi-
Fields inherited from class org.apache.bcel.generic.InstructionHandle
EMPTY_ARRAY, EMPTY_INSTRUCTION_TARGETER_ARRAY, i_position
-
-
Constructor Summary
Constructors Modifier Constructor Description privateBranchHandle(BranchInstruction i)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static BranchHandlegetBranchHandle(BranchInstruction i)Factory method.intgetPosition()InstructionHandlegetTarget()voidsetInstruction(Instruction i)Sets new contents.(package private) voidsetPosition(int pos)Sets the position, i.e., the byte code offset of the contained instruction.voidsetTarget(InstructionHandle ih)Pass new target to instruction.protected intupdatePosition(int offset, int maxOffset)Called by InstructionList.setPositions when setting the position for every instruction.voidupdateTarget(InstructionHandle oldIh, InstructionHandle newIh)Update target of instruction.-
Methods inherited from class org.apache.bcel.generic.InstructionHandle
accept, addAttribute, addHandle, addTargeter, dispose, getAttribute, getAttributes, getInstruction, getInstructionHandle, getNext, getPrev, getTargeters, hasTargeters, removeAllTargeters, removeAttribute, removeTargeter, setNext, setPrev, swapInstruction, toString, toString
-
-
-
-
Field Detail
-
bi
private BranchInstruction bi
-
-
Constructor Detail
-
BranchHandle
private BranchHandle(BranchInstruction i)
-
-
Method Detail
-
getBranchHandle
static BranchHandle getBranchHandle(BranchInstruction i)
Factory method.
-
getPosition
public int getPosition()
- Overrides:
getPositionin classInstructionHandle- Returns:
- the position, i.e., the byte code offset of the contained instruction. This is accurate only after InstructionList.setPositions() has been called.
-
getTarget
public InstructionHandle getTarget()
- Returns:
- target of instruction.
-
setInstruction
public void setInstruction(Instruction i)
Sets new contents. Old instruction is disposed and may not be used anymore.- Overrides:
setInstructionin classInstructionHandle
-
setPosition
void setPosition(int pos)
Description copied from class:InstructionHandleSets the position, i.e., the byte code offset of the contained instruction.- Overrides:
setPositionin classInstructionHandle
-
setTarget
public void setTarget(InstructionHandle ih)
Pass new target to instruction.
-
updatePosition
protected int updatePosition(int offset, int maxOffset)Description copied from class:InstructionHandleCalled 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:
updatePositionin classInstructionHandle- Parameters:
offset- additional offset caused by preceding (variable length) instructionsmaxOffset- 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.
-
-