Package org.apache.bcel.generic
Class CPInstruction
- java.lang.Object
-
- org.apache.bcel.generic.Instruction
-
- org.apache.bcel.generic.CPInstruction
-
- All Implemented Interfaces:
java.lang.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:
ConstantPoolGen,LDC,INVOKEVIRTUAL
-
-
Field Summary
Fields Modifier and Type Field Description protected intindexDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter-
Fields inherited from class org.apache.bcel.generic.Instruction
EMPTY_ARRAY, length, opcode
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)CPInstruction()Empty constructor needed for Instruction.readInstruction.protectedCPInstruction(short opcode, int index)Constructs a CPInstruction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddump(java.io.DataOutputStream out)Dumps instruction as byte code to stream out.intgetIndex()Gets the index.TypegetType(ConstantPoolGen cpg)Gets the type associated with this instruction.protected voidinitFromFile(ByteSequence bytes, boolean wide)Reads needed data (that is, index) from file.voidsetIndex(int index)Sets the index to constant pool.java.lang.StringtoString(boolean verbose)Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< constant pool index>">"java.lang.StringtoString(ConstantPool cp)Gets the mnemonic for instruction with symbolic references resolved.-
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
-
-
-
-
Method Detail
-
dump
public void dump(java.io.DataOutputStream out) throws java.io.IOExceptionDumps instruction as byte code to stream out.- Overrides:
dumpin classInstruction- Parameters:
out- Output stream.- Throws:
java.io.IOException- Thrown when an I/O exception of some sort has occurred.
-
getIndex
public final int getIndex()
Description copied from interface:IndexedInstructionGets the index.- Specified by:
getIndexin interfaceIndexedInstruction- Returns:
- index in constant pool referred by this instruction.
-
getType
public Type getType(ConstantPoolGen cpg)
Description copied from interface:TypedInstructionGets the type associated with this instruction.- Specified by:
getTypein interfaceTypedInstruction- Parameters:
cpg- the constant pool generator.- Returns:
- type related with this instruction.
-
initFromFile
protected void initFromFile(ByteSequence bytes, boolean wide) throws java.io.IOException
Reads needed data (that is, index) from file.- Overrides:
initFromFilein classInstruction- Parameters:
bytes- input stream.wide- wide prefix?.- Throws:
java.io.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
public java.lang.String toString(boolean verbose)
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
public java.lang.String toString(ConstantPool cp)
Description copied from class:InstructionGets the mnemonic for instruction with symbolic references resolved.- Overrides:
toStringin classInstruction- Parameters:
cp- the constant pool.- Returns:
- mnemonic for instruction with symbolic references resolved.
-
-