org.apache.bcel.generic

Class CPInstruction

Implemented Interfaces:
Cloneable, IndexedInstruction, Serializable, TypedInstruction
Known Direct Subclasses:
ANEWARRAY, CHECKCAST, FieldOrMethod, INSTANCEOF, LDC, LDC2_W, MULTIANEWARRAY, 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.
Version:
$Id: CPInstruction.java,v 1.1.1.1 2001/10/29 20:00:07 jvanzyl Exp $
Author:
M. Dahm
See Also:
ConstantPoolGen, LDC, INVOKEVIRTUAL

Field Summary

protected int
index

Fields inherited from class org.apache.bcel.generic.Instruction

length, opcode

Constructor Summary

CPInstruction(short opcode, int index)

Method Summary

void
dump(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.
String
toString(boolean verbose)
Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< constant pool index>">"
String
toString(ConstantPool cp)

Methods inherited from class org.apache.bcel.generic.Instruction

accept, consumeStack, copy, dump, equals, getComparator, getLength, getName, getOpcode, initFromFile, produceStack, readInstruction, setComparator, toString, toString, toString

Field Details

index

protected int index

Constructor Details

CPInstruction

protected CPInstruction(short opcode,
                        int index)
Parameters:
index - to constant pool

Method Details

dump

public void dump(DataOutputStream out)
            throws IOException
Dump instruction as byte code to stream out.
Overrides:
dump in interface Instruction
Parameters:
out - Output stream

getIndex

public final int getIndex()
Specified by:
getIndex in interface IndexedInstruction
Returns:
index in constant pool referred by this instruction.

getType

public Type getType(ConstantPoolGen cpg)
Specified by:
getType in interface TypedInstruction
Returns:
type related with this instruction.

initFromFile

protected void initFromFile(ByteSequence bytes,
                            boolean wide)
            throws IOException
Read needed data (i.e., index) from file.
Overrides:
initFromFile in interface Instruction
Parameters:
bytes - input stream
wide - wide prefix?

setIndex

public void setIndex(int index)
Set the index to constant pool.
Specified by:
setIndex in interface IndexedInstruction
Parameters:
index - in constant pool.

toString

public String toString(boolean verbose)
Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< constant pool index>">"
Overrides:
toString in interface Instruction
Parameters:
verbose - long/short format switch
Returns:
mnemonic for instruction

toString

public String toString(ConstantPool cp)
Overrides:
toString in interface Instruction
Returns:
mnemonic for instruction with symbolic references resolved