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 super class for LOOKUPSWITCH and TABLESWITCH instructions.
We use our super's target
property as the default target.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected 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 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 int
Deprecated.(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, target
Fields 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 Object
clone()
boolean
Checks whether this targeter targets the specified instruction handle.(package private) void
dispose()
Inform targets that they're not targeted anymore.void
dump
(DataOutputStream out) Dump instruction as byte code to stream out.(package private) final int
int[]
(package private) final int
getIndices
(int index) (package private) final int
getMatch
(int index) (package private) final int
int[]
(package private) final int
(package private) final InstructionHandle
getTarget
(int index) protected void
initFromFile
(ByteSequence bytes, boolean wide) Read needed data (e.g.(package private) final void
setFixedLength
(int fixedLength) (package private) final void
setIndices
(int[] array) (package private) final int
setIndices
(int i, int value) (package private) final void
setMatch
(int index, int value) (package private) final void
setMatches
(int[] array) (package private) final int
setMatchLength
(int matchLength) void
setTarget
(int i, InstructionHandle target) Sets branch target for 'i'th case(package private) final void
setTargets
(InstructionHandle[] array) toString
(boolean verbose) Long output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>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.void
updateTarget
(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, setTarget
Methods inherited from class org.apache.bcel.generic.Instruction
accept, consumeStack, copy, equals, getComparator, getLength, getName, getOpcode, hashCode, isValidByte, isValidShort, produceStack, readInstruction, setComparator, setLength, setOpcode, toString, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.bcel.generic.StackConsumer
consumeStack
Methods 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 valuestargets
- instruction targetsdefaultTarget
- default instruction target
-
-
Method Details
-
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
containsTarget
Description copied from interface:InstructionTargeter
Checks whether this targeter targets the specified instruction handle.- Specified by:
containsTarget
in interfaceInstructionTargeter
- Overrides:
containsTarget
in classBranchInstruction
- Returns:
- true, if ih is target of this instruction
-
dispose
void dispose()Inform targets that they're not targeted anymore.- Overrides:
dispose
in classBranchInstruction
-
dump
Dump instruction as byte code to stream out.- Overrides:
dump
in classBranchInstruction
- Parameters:
out
- Output stream- Throws:
IOException
- Thrown when an I/O exception of some sort has occurred.
-
getFixedLength
final int getFixedLength()- Returns:
- the fixed_length
- Since:
- 6.0
-
getIndices
public int[] getIndices()- Returns:
- array of match target offsets
-
getIndices
final int getIndices(int index) - Returns:
- index entry from indices
- Since:
- 6.0
-
getMatch
final int getMatch(int index) - Returns:
- match entry
- Since:
- 6.0
-
getMatchLength
final int getMatchLength()- Returns:
- the match_length
- Since:
- 6.0
-
getMatchs
public int[] getMatchs()- Returns:
- array of match indices
-
getPadding
final int getPadding()- Returns:
- the padding
- Since:
- 6.0
-
getTarget
- Returns:
- target entry
- Since:
- 6.0
-
getTargets
- Returns:
- array of match targets
-
initFromFile
Read needed data (e.g. index) from file.- Overrides:
initFromFile
in classBranchInstruction
- Parameters:
bytes
- input streamwide
- wide prefix?- Throws:
IOException
- may be thrown if the implementation needs to read data from the file- See Also:
-
setFixedLength
final void setFixedLength(int fixedLength) - Parameters:
fixedLength
- the fixed_length to set- Since:
- 6.0
-
setIndices
final int setIndices(int i, int value) - Since:
- 6.0
-
setIndices
final void setIndices(int[] array) - Parameters:
array
-- Since:
- 6.0
-
setMatch
final void setMatch(int index, int value) - Parameters:
index
-value
-- Since:
- 6.0
-
setMatches
final void setMatches(int[] array) - Parameters:
array
-- Since:
- 6.0
-
setMatchLength
final int setMatchLength(int matchLength) - Parameters:
matchLength
- the match_length to set- Since:
- 6.0
-
setTarget
Sets branch target for 'i'th case -
setTargets
- Parameters:
array
-- Since:
- 6.0
-
toString
Description copied from class:BranchInstruction
Long output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>- Overrides:
toString
in 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:
updatePosition
in classBranchInstruction
- 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
Description copied from interface:InstructionTargeter
Replaces the target of this targeter from this old handle to the new handle.- Specified by:
updateTarget
in interfaceInstructionTargeter
- Overrides:
updateTarget
in classBranchInstruction
- Parameters:
oldIh
- old targetnewIh
- new target
-