# Class FieldInstruction

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

All Implemented Interfaces:
  `Cloneable, IndexedInstruction, LoadClass, TypedInstruction`

Direct Known Subclasses:
  `GETFIELD, GETSTATIC, PUTFIELD, PUTSTATIC`

public abstract class FieldInstruction extends FieldOrMethod
Super class for the GET/PUTxxx family of instructions.

- ## Field Summary

  ### Fields inherited from class CPInstruction

  `index`

  ### Fields inherited from class Instruction

  `length, opcode`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `FieldInstruction(short opcode, int index)`
  Constructs a FieldInstruction.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getFieldName(ConstantPoolGen cpg)`
  Gets the name of referenced field.
  `protected int`
  `getFieldSize(ConstantPoolGen cpg)`
  Gets the size of field.
  `Type`
  `getFieldType(ConstantPoolGen cpg)`
  Gets the type of field.
  `Type`
  `getType(ConstantPoolGen cpg)`
  Gets the type associated with this instruction.
  `String`
  `toString(ConstantPool cp)`
  Gets the mnemonic for instruction with symbolic references resolved.

  ### Methods inherited from class FieldOrMethod

  `getClassName, getClassType, getLoadClassType, getName, getReferenceType, getSignature`

  ### Methods inherited from class CPInstruction

  `dump, getIndex, initFromFile, setIndex, toString`

  ### Methods inherited from class Instruction

  `accept, consumeStack, copy, equals, getComparator, getLength, getName, getOpcode, hashCode, isValidByte, isValidShort, produceStack, readInstruction, setComparator, toString`

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### FieldInstruction

    protected FieldInstruction(short opcode, int index)
    Constructs a FieldInstruction.
    Parameters:
      `opcode` - the opcode.
      `index` - to constant pool.

- ## Method Details

  - ### getFieldName

    public String getFieldName(ConstantPoolGen cpg)
    Gets the name of referenced field.
    Parameters:
      `cpg` - the constant pool generator.
    Returns:
      name of referenced field.

  - ### getFieldSize

    protected int getFieldSize(ConstantPoolGen cpg)
    Gets the size of field.
    Parameters:
      `cpg` - the constant pool generator.
    Returns:
      size of field (1 or 2).

  - ### getFieldType

    public Type getFieldType(ConstantPoolGen cpg)
    Gets the type of field.
    Parameters:
      `cpg` - the constant pool generator.
    Returns:
      type of field.

  - ### getType

    public Type getType(ConstantPoolGen cpg)
    Description copied from interface: `TypedInstruction`
    Gets the type associated with this instruction.
    Specified by:
      `getType` in interface `LoadClass`
    Specified by:
      `getType` in interface `TypedInstruction`
    Overrides:
      `getType` in class `CPInstruction`
    Parameters:
      `cpg` - the constant pool generator.
    Returns:
      return type of referenced field.
    See Also:
      - `LoadClass.getLoadClassType(ConstantPoolGen)`

  - ### toString

    public String toString(ConstantPool cp)
    Description copied from class: `Instruction`
    Gets the mnemonic for instruction with symbolic references resolved.
    Overrides:
      `toString` in class `CPInstruction`
    Parameters:
      `cp` - the constant pool.
    Returns:
      mnemonic for instruction with symbolic references resolved.