Package org.apache.bcel.generic
Class Select
java.lang.Object
org.apache.bcel.generic.Instruction
org.apache.bcel.generic.BranchInstruction
org.apache.bcel.generic.Select
- All Implemented Interfaces:
Cloneable,InstructionTargeter,StackConsumer,StackProducer,VariableLengthInstruction
- Direct Known Subclasses:
LOOKUPSWITCH,TABLESWITCH
public abstract class Select
extends BranchInstruction
implements VariableLengthInstruction, StackConsumer, StackProducer
Select - Abstract superclass for LOOKUPSWITCH and TABLESWITCH instructions.
We use our super's target property as the default target.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected int[]Deprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected int[]Deprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected intDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected intDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected InstructionHandle[]Deprecated.(since 6.0) will be made private; do not access directly, use getter/setterFields inherited from class org.apache.bcel.generic.BranchInstruction
index, position, targetFields inherited from class org.apache.bcel.generic.Instruction
EMPTY_ARRAY, length, opcode -
Constructor Summary
ConstructorsConstructorDescriptionSelect()Empty constructor needed for Instruction.readInstruction.Select(short opcode, int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget) (Match, target) pairs for switch. -
Method Summary
Modifier and TypeMethodDescriptionprotected Objectclone()booleanTests whether this targeter targets the specified instruction handle.(package private) voiddispose()Inform targets that they're not targeted anymore.voiddump(DataOutputStream out) Dumps instruction as byte code to stream out.(package private) final intGets the instruction length without padding.int[]Gets the match target offsets.(package private) final intgetIndices(int index) Gets the target offset at the given index.(package private) final intgetMatch(int index) Gets the match value at the given index.(package private) final intGets the number of match values.int[]Gets the match indices.(package private) final intGets the number of padding bytes.(package private) final InstructionHandlegetTarget(int index) Gets the target at the given index.Gets the match targets.protected voidinitFromFile(ByteSequence bytes, boolean wide) Reads needed data (for example index) from file.(package private) final voidsetFixedLength(int fixedLength) Sets the instruction length without padding.(package private) final voidsetIndices(int[] array) Sets the target offsets.(package private) final intsetIndices(int i, int value) Sets the target offset at the given index.(package private) final voidsetMatch(int index, int value) Sets the match value at the given index.(package private) final voidsetMatches(int[] array) Sets the match values.(package private) final intsetMatchLength(int matchLength) Sets the number of match values.voidsetTarget(int i, InstructionHandle target) Sets branch target for 'i'th case.(package private) final voidsetTargets(InstructionHandle[] array) Sets the match targets.toString(boolean verbose) Long output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>protected intupdatePosition(int offset, int maxOffset) Since this is a variable length instruction, it may shift the following instructions which then need to update their position.voidupdateTarget(InstructionHandle oldIh, InstructionHandle newIh) Replaces the target of this targeter from this old handle to the new handle.Methods inherited from class org.apache.bcel.generic.BranchInstruction
getIndex, getPosition, getTarget, getTargetOffset, getTargetOffset, notifyTarget, setIndex, setPosition, setTargetMethods inherited from class org.apache.bcel.generic.Instruction
accept, consumeStack, copy, dumpToByteArray, equals, getComparator, getLength, getName, getOpcode, hashCode, isNonNegativeUShort, isValidByte, isValidShort, produceStack, readInstruction, readInstruction, setComparator, setLength, setOpcode, toString, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.bcel.generic.StackConsumer
consumeStackMethods inherited from interface org.apache.bcel.generic.StackProducer
produceStack
-
Field Details
-
match
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter -
indices
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter -
targets
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter -
fixed_length
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter -
match_length
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter -
padding
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
-
Constructor Details
-
Select
Select()Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. -
Select
Select(short opcode, int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget) (Match, target) pairs for switch. 'Match' and 'targets' must have the same length of course.- Parameters:
match- array of matching values.targets- instruction targets.defaultTarget- default instruction target.
-
-
Method Details
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
containsTarget
Description copied from interface:InstructionTargeterTests whether this targeter targets the specified instruction handle.- Specified by:
containsTargetin interfaceInstructionTargeter- Overrides:
containsTargetin classBranchInstruction- Parameters:
ih- The instruction handle to test.- Returns:
- true, if ih is target of this instruction.
-
dispose
void dispose()Inform targets that they're not targeted anymore.- Overrides:
disposein classBranchInstruction
-
dump
Dumps instruction as byte code to stream out.- Overrides:
dumpin classBranchInstruction- Parameters:
out- Output stream.- Throws:
IOException- Thrown when an I/O exception of some sort has occurred.
-
getFixedLength
final int getFixedLength()Gets the instruction length without padding.- Returns:
- The fixed_length.
- Since:
- 6.0
-
getIndices
public int[] getIndices()Gets the match target offsets.- Returns:
- array of match target offsets.
-
getIndices
final int getIndices(int index) Gets the target offset at the given index.- Returns:
- index entry from indices.
- Since:
- 6.0
-
getMatch
final int getMatch(int index) Gets the match value at the given index.- Returns:
- match entry.
- Since:
- 6.0
-
getMatchLength
final int getMatchLength()Gets the number of match values.- Returns:
- The match_length.
- Since:
- 6.0
-
getMatchs
public int[] getMatchs()Gets the match indices.- Returns:
- array of match indices.
-
getPadding
final int getPadding()Gets the number of padding bytes.- Returns:
- The padding.
- Since:
- 6.0
-
getTarget
Gets the target at the given index.- Returns:
- target entry.
- Since:
- 6.0
-
getTargets
Gets the match targets.- Returns:
- array of match targets.
-
initFromFile
Reads needed data (for example index) from file.- Overrides:
initFromFilein classBranchInstruction- Parameters:
bytes- input stream.wide- wide prefix?- Throws:
IOException- Thrown if the implementation needs to read data from the file- See Also:
-
setFixedLength
final void setFixedLength(int fixedLength) Sets the instruction length without padding.- Parameters:
fixedLength- The fixed_length to set.- Since:
- 6.0
-
setIndices
final int setIndices(int i, int value) Sets the target offset at the given index.- Since:
- 6.0
-
setIndices
final void setIndices(int[] array) Sets the target offsets.- Parameters:
array- The new target offsets.- Since:
- 6.0
-
setMatch
final void setMatch(int index, int value) Sets the match value at the given index.- Parameters:
index- The match index.value- The match value.- Since:
- 6.0
-
setMatches
final void setMatches(int[] array) Sets the match values.- Parameters:
array- The new match values.- Since:
- 6.0
-
setMatchLength
final int setMatchLength(int matchLength) Sets the number of match values.- Parameters:
matchLength- The match_length to set.- Since:
- 6.0
-
setTarget
Sets branch target for 'i'th case.- Parameters:
i- The case index.target- The branch target.
-
setTargets
Sets the match targets.- Parameters:
array- The new match targets.- Since:
- 6.0
-
toString
Description copied from class:BranchInstructionLong output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>- Overrides:
toStringin classBranchInstruction- Parameters:
verbose- long/short format switch.- Returns:
- mnemonic for instruction.
-
updatePosition
protected int updatePosition(int offset, int maxOffset) Since this is a variable length instruction, it may shift the following instructions which then need to update their position. 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:
updatePositionin classBranchInstruction- 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
Description copied from interface:InstructionTargeterReplaces the target of this targeter from this old handle to the new handle.- Specified by:
updateTargetin interfaceInstructionTargeter- Overrides:
updateTargetin classBranchInstruction- Parameters:
oldIh- old target.newIh- new target.
-