Package org.apache.bcel.generic
Class CPInstruction
java.lang.Object
org.apache.bcel.generic.Instruction
org.apache.bcel.generic.CPInstruction
- All Implemented Interfaces:
Cloneable
,IndexedInstruction
,TypedInstruction
- Direct Known Subclasses:
ANEWARRAY
,CHECKCAST
,FieldOrMethod
,INSTANCEOF
,LDC
,LDC2_W
,MULTIANEWARRAY
,NameSignatureInstruction
,NEW
public abstract class CPInstruction
extends Instruction
implements TypedInstruction, IndexedInstruction
Abstract super class for instructions that use an index into the constant pool such as LDC, INVOKEVIRTUAL, etc.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setterFields inherited from class org.apache.bcel.generic.Instruction
EMPTY_ARRAY, length, opcode
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
Empty constructor needed for Instruction.readInstruction.protected
CPInstruction
(short opcode, int index) -
Method Summary
Modifier and TypeMethodDescriptionvoid
dump
(DataOutputStream out) Dump instruction as byte code to stream out.final int
getIndex()
getType
(ConstantPoolGen cpg) protected void
initFromFile
(ByteSequence bytes, boolean wide) Read needed data (i.e., index) from file.void
setIndex
(int index) Sets the index to constant pool.toString
(boolean verbose) Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< constant pool index>">"toString
(ConstantPool cp) Methods inherited from class org.apache.bcel.generic.Instruction
accept, consumeStack, copy, dispose, equals, getComparator, getLength, getName, getOpcode, hashCode, isValidByte, isValidShort, produceStack, readInstruction, setComparator, setLength, setOpcode, toString
-
Field Details
-
index
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
-
Constructor Details
-
CPInstruction
CPInstruction()Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. -
CPInstruction
protected CPInstruction(short opcode, int index) - Parameters:
index
- to constant pool
-
-
Method Details
-
dump
Dump instruction as byte code to stream out.- Overrides:
dump
in classInstruction
- Parameters:
out
- Output stream- Throws:
IOException
- Thrown when an I/O exception of some sort has occurred.
-
getIndex
public final int getIndex()- Specified by:
getIndex
in interfaceIndexedInstruction
- Returns:
- index in constant pool referred by this instruction.
-
getType
- Specified by:
getType
in interfaceTypedInstruction
- Returns:
- type related with this instruction.
-
initFromFile
Read needed data (i.e., index) from file.- Overrides:
initFromFile
in classInstruction
- Parameters:
bytes
- input streamwide
- wide prefix?- Throws:
IOException
- may be thrown if the implementation needs to read data from the file
-
setIndex
public void setIndex(int index) Sets the index to constant pool.- Specified by:
setIndex
in interfaceIndexedInstruction
- Parameters:
index
- in constant pool.
-
toString
Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< constant pool index>">"- Overrides:
toString
in classInstruction
- Parameters:
verbose
- long/short format switch- Returns:
- mnemonic for instruction
-
toString
- Overrides:
toString
in classInstruction
- Returns:
- mnemonic for instruction with symbolic references resolved
-