Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.bcel.generic
Class CPInstruction

    java.lang.Object
      org.apache.bcel.generic.Instruction
          org.apache.bcel.generic.CPInstruction

All Implemented Interfaces:
  Serializable, Cloneable, IndexedInstruction, TypedInstruction

Direct Known 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 386056 2006-03-15 11:31:56Z tcurdt $
See Also:
  `ConstantPoolGen`, `LDC`, `INVOKEVIRTUAL`, Serialized Form

Field Summary
`protected int` | `index`

Fields inherited from class org.apache.bcel.generic.Instruction
`length, opcode`

Constructor Summary
`protected` | `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, equals, getComparator, getLength, getName, getOpcode, produceStack, readInstruction, setComparator, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### index

    protected int index

Constructor Detail

### CPInstruction

    protected CPInstruction(short opcode,
                            int index)

Parameters:
  `index` - to constant pool

Method Detail

### dump

    public void dump(DataOutputStream out)
              throws IOException

  Dump instruction as byte code to stream out.

  Overrides:
    `dump` in class `Instruction`
  Parameters:
    `out` - Output stream
  Throws:
    `IOException`

### toString

    public String toString(boolean verbose)

  Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< constant pool index>">"

  Overrides:
    `toString` in class `Instruction`
  Parameters:
    `verbose` - long/short format switch
  Returns:
    mnemonic for instruction

### toString

    public String toString(ConstantPool cp)

  Overrides:
    `toString` in class `Instruction`
  Returns:
    mnemonic for instruction with symbolic references resolved

### initFromFile

    protected void initFromFile(ByteSequence bytes,
                                boolean wide)
                         throws IOException

  Read needed data (i.e., index) from file.

  Overrides:
    `initFromFile` in class `Instruction`
  Parameters:
    `bytes` - input stream
    `wide` - wide prefix?
  Throws:
    `IOException`

### getIndex

    public final int getIndex()

  Specified by:
    `getIndex` in interface `IndexedInstruction`
  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 interface `IndexedInstruction`
  Parameters:
    `index` - in constant pool.

### getType

    public Type getType(ConstantPoolGen cpg)

  Specified by:
    `getType` in interface `TypedInstruction`
  Returns:
    type related with this instruction.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2006 Apache Software Foundation. All Rights Reserved.