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 int
index
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter-
Fields inherited from class org.apache.bcel.generic.Instruction
length, opcode
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CPInstruction(short opcode, int index)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dump(java.io.DataOutputStream out)
Dump instruction as byte code to stream out.int
getIndex()
Type
getType(ConstantPoolGen cpg)
protected void
initFromFile(ByteSequence bytes, boolean wide)
Read needed data (i.e., index) from file.void
setIndex(int index)
Set the index to constant pool.java.lang.String
toString(boolean verbose)
Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< constant pool index>">"java.lang.String
toString(ConstantPool cp)
-
Methods inherited from class org.apache.bcel.generic.Instruction
accept, consumeStack, copy, equals, getComparator, getLength, getName, getOpcode, hashCode, isValidByte, isValidShort, produceStack, readInstruction, setComparator, toString
-
-
-
-
Method Detail
-
dump
public void dump(java.io.DataOutputStream out) throws java.io.IOException
Dump instruction as byte code to stream out.- Overrides:
dump
in classInstruction
- Parameters:
out
- Output stream- Throws:
java.io.IOException
-
toString
public java.lang.String toString(boolean verbose)
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
public java.lang.String toString(ConstantPool cp)
- Overrides:
toString
in classInstruction
- Returns:
- mnemonic for instruction with symbolic references resolved
-
initFromFile
protected void initFromFile(ByteSequence bytes, boolean wide) throws java.io.IOException
Read needed data (i.e., index) from file.- Overrides:
initFromFile
in classInstruction
- Parameters:
bytes
- input streamwide
- wide prefix?- Throws:
java.io.IOException
- may be thrown if the implementation needs to read data from the file
-
getIndex
public final int getIndex()
- Specified by:
getIndex
in interfaceIndexedInstruction
- Returns:
- index in constant pool referred by this instruction.
-
setIndex
public void setIndex(int index)
Set the index to constant pool.- Specified by:
setIndex
in interfaceIndexedInstruction
- Parameters:
index
- in constant pool.
-
getType
public Type getType(ConstantPoolGen cpg)
- Specified by:
getType
in interfaceTypedInstruction
- Returns:
- type related with this instruction.
-
-