Top Description Fields Constructors Methods
org.aspectj.apache.bcel.generic

public Class InstructionBranch

extends Instruction
implements InstructionTargeter
Class Inheritance
All Implemented Interfaces
org.aspectj.apache.bcel.generic.InstructionTargeter
Known Direct Subclasses
org.aspectj.apache.bcel.generic.InstructionSelect
Imports
java.io.DataOutputStream, .IOException, org.aspectj.apache.bcel.Constants, org.aspectj.apache.bcel.classfile.ConstantPool

Abstract super class for branching instructions like GOTO, IFEQ, etc.. Branch instructions may have a variable length, namely GOTO, JSR, LOOKUPSWITCH and TABLESWITCH. A branch instruction may be talking in terms of absolute destination (targetIndex) or about an instruction it doesnt yet know the position if (targetInstruction). targetInstruction (if set) overrides targetIndex
Author
M. Dahm
Version
$Id: InstructionBranch.java,v 1.6 2009/10/05 17:35:36 aclement Exp $
See Also
InstructionList

Field Summary

Modifier and TypeField and Description
protected int
protected int
protected InstructionHandle
private static final int
Inherited from org.aspectj.apache.bcel.generic.Instruction:
opcode

Constructor Summary

AccessConstructor and Description
public
InstructionBranch(short opcode, InstructionHandle target)

public
InstructionBranch(short opcode, int index)

public
InstructionBranch(short opcode)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true, if ih is target of this instruction
containsTarget
(InstructionHandle ih)

Implements org.aspectj.apache.bcel.generic.InstructionTargeter.containsTarget.

pack-priv void
dispose()

Overrides org.aspectj.apache.bcel.generic.Instruction.dispose.

Inform target that it's not targeted anymore.
public void
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides org.aspectj.apache.bcel.generic.Instruction.equals.

Only equal if they are the same branch instruction - otherwise too risky as the targets may only temporarily be pointing at the same destination.
public final int

Returns:

target offset in byte code
getIndex
()

Overrides org.aspectj.apache.bcel.generic.Instruction.getIndex.

public InstructionHandle

Returns:

target of branch instruction
getTarget
()

protected int
public Type
public int
hashCode()

Overrides org.aspectj.apache.bcel.generic.Instruction.hashCode.

Returns a hash code value for the object.
public boolean
pack-priv static final void
notifyTarget(InstructionHandle oldHandle, InstructionHandle newHandle, InstructionTargeter t)

Used by BranchInstruction, LocalVariableGen, CodeExceptionGen

public InstructionHandle

Returns:

an InstructionHandle to the "next" instruction that will be executed when RETurned from a subroutine.
physicalSuccessor
()

Returns an InstructionHandle to the physical successor of this JsrInstruction.

public void
setTarget(InstructionHandle
branch target
target
)

Set branch target

public String

Returns:

mnemonic for instruction
toString
(boolean
long/short format switch
verbose
)

Overrides org.aspectj.apache.bcel.generic.Instruction.toString.

Long output format:
protected int

Returns:

additional offset caused by possible change of this instruction's length
updatePosition
(int
additional offset caused by preceding (variable length) instructions
offset
,
int
the maximum offset that may be caused by these instructions
max_offset
)

Called by InstructionList.setPositions when setting the position for every instruction.

public void
updateTarget(InstructionHandle
old target
oldHandle
,
InstructionHandle
new target
newHandle
)

Implements org.aspectj.apache.bcel.generic.InstructionTargeter.updateTarget.

Update the target destination for this instruction.
Inherited from org.aspectj.apache.bcel.generic.Instruction:
consumeStackcopygetLengthgetLoadClassTypegetNamegetOpcodegetTypegetValuegetValueisALOADisArrayCreationInstructionisASTOREisConstantInstructionisConstantPoolInstructionisIndexedInstructionisJsrInstructionisLoadInstructionisLocalVariableInstructionisReturnInstructionisStackConsumerisStackProducerisStoreInstructionproduceStackreadInstructionsetIndextoString

Field Detail

positionOfThisInstructionback to summary
protected int positionOfThisInstruction
targetIndexback to summary
protected int targetIndex
targetInstructionback to summary
protected InstructionHandle targetInstruction
UNSETback to summary
private static final int UNSET

Constructor Detail

InstructionBranchback to summary
public InstructionBranch(short opcode, InstructionHandle target)
InstructionBranchback to summary
public InstructionBranch(short opcode, int index)
InstructionBranchback to summary
public InstructionBranch(short opcode)

Method Detail

containsTargetback to summary
public boolean containsTarget(InstructionHandle ih)

Implements org.aspectj.apache.bcel.generic.InstructionTargeter.containsTarget.

Returns:boolean

true, if ih is target of this instruction

disposeback to summary
pack-priv void dispose()

Overrides org.aspectj.apache.bcel.generic.Instruction.dispose.

Inform target that it's not targeted anymore.

dumpback to summary
public void dump(DataOutputStream out) throws IOException

Overrides org.aspectj.apache.bcel.generic.Instruction.dump.

equalsback to summary
public boolean equals(Object other)

Overrides org.aspectj.apache.bcel.generic.Instruction.equals.

Only equal if they are the same branch instruction - otherwise too risky as the targets may only temporarily be pointing at the same destination.

Parameters
other:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

getIndexback to summary
public final int getIndex()

Overrides org.aspectj.apache.bcel.generic.Instruction.getIndex.

Returns:int

target offset in byte code

getTargetback to summary
public InstructionHandle getTarget()
Returns:InstructionHandle

target of branch instruction

getTargetOffsetback to summary
protected int getTargetOffset()
getTypeback to summary
public Type getType(ConstantPool cp)

Overrides org.aspectj.apache.bcel.generic.Instruction.getType.

hashCodeback to summary
public int hashCode()

Overrides org.aspectj.apache.bcel.generic.Instruction.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

isIfInstructionback to summary
public boolean isIfInstruction()
notifyTargetback to summary
pack-priv static final void notifyTarget(InstructionHandle oldHandle, InstructionHandle newHandle, InstructionTargeter t)

Used by BranchInstruction, LocalVariableGen, CodeExceptionGen

physicalSuccessorback to summary
public InstructionHandle physicalSuccessor()

Returns an InstructionHandle to the physical successor of this JsrInstruction. For this method to work, this JsrInstruction object must not be shared between multiple InstructionHandle objects! Formally, there must not be InstructionHandle objects i, j where i != j and i.getInstruction() == this == j.getInstruction().

Returns:InstructionHandle

an InstructionHandle to the "next" instruction that will be executed when RETurned from a subroutine.

setTargetback to summary
public void setTarget(InstructionHandle target)

Set branch target

Parameters
target:InstructionHandle

branch target

toStringback to summary
public String toString(boolean verbose)

Overrides org.aspectj.apache.bcel.generic.Instruction.toString.

Long output format:

Parameters
verbose:boolean

long/short format switch

Returns:String

mnemonic for instruction

updatePositionback to summary
protected int updatePosition(int offset, int max_offset)

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.

Parameters
offset:int

additional offset caused by preceding (variable length) instructions

max_offset:int

the maximum offset that may be caused by these instructions

Returns:int

additional offset caused by possible change of this instruction's length

updateTargetback to summary
public void updateTarget(InstructionHandle oldHandle, InstructionHandle newHandle)

Implements org.aspectj.apache.bcel.generic.InstructionTargeter.updateTarget.

Update the target destination for this instruction. If an oldHandle is provided it is checked to verify that is where the target currently points to before changing it.

Parameters
oldHandle:InstructionHandle

old target

newHandle:InstructionHandle

new target