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 intDeprecated.(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.protectedCPInstruction(short opcode, int index) -
Method Summary
Modifier and TypeMethodDescriptionvoiddump(DataOutputStream out) Dump instruction as byte code to stream out.final intgetIndex()getType(ConstantPoolGen cpg) protected voidinitFromFile(ByteSequence bytes, boolean wide) Read needed data (i.e., index) from file.voidsetIndex(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:
dumpin 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:
getIndexin interfaceIndexedInstruction- Returns:
- index in constant pool referred by this instruction.
-
getType
- Specified by:
getTypein interfaceTypedInstruction- Returns:
- type related with this instruction.
-
initFromFile
Read needed data (i.e., index) from file.- Overrides:
initFromFilein 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:
setIndexin interfaceIndexedInstruction- Parameters:
index- in constant pool.
-
toString
Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< constant pool index>">"- Overrides:
toStringin classInstruction- Parameters:
verbose- long/short format switch- Returns:
- mnemonic for instruction
-
toString
- Overrides:
toStringin classInstruction- Returns:
- mnemonic for instruction with symbolic references resolved
-