Class ConstantCP

java.lang.Object
org.apache.bcel.classfile.Constant
org.apache.bcel.classfile.ConstantCP
All Implemented Interfaces:
Cloneable, Node
Direct Known Subclasses:
ConstantDynamic, ConstantFieldref, ConstantInterfaceMethodref, ConstantInvokeDynamic, ConstantMethodref

public abstract class ConstantCP extends Constant
Abstract super class for Fieldref, Methodref, InterfaceMethodref and InvokeDynamic constants.
See Also:
  • Field Details

    • class_index

      @Deprecated protected int class_index
      Deprecated.
      (since 6.0) will be made private; do not access directly, use getter/setter.
    • name_and_type_index

      Deprecated.
      (since 6.0) will be made private; do not access directly, use getter/setter.
  • Constructor Details

    • ConstantCP

      protected ConstantCP(byte tag, int classIndex, int nameAndTypeIndex)
      Constructs a ConstantCP.
      Parameters:
      tag - the constant type tag.
      classIndex - Reference to the class containing the field.
      nameAndTypeIndex - and the field signature.
    • ConstantCP

      Initialize from another object.
      Parameters:
      c - Source to copy.
  • Method Details

    • dump

      public final void dump(DataOutputStream file) throws IOException
      Dumps constant field reference to file stream in binary format.
      Specified by:
      dump in class Constant
      Parameters:
      file - Output file stream.
      Throws:
      IOException - if an I/O error occurs.
    • getClass

      Gets the class this field belongs to.
      Parameters:
      cp - the constant pool.
      Returns:
      Class this field belongs to.
    • getClassIndex

      public final int getClassIndex()
      Gets the reference (index) to class this constant refers to.
      Returns:
      Reference (index) to class this constant refers to.
    • getNameAndTypeIndex

      public final int getNameAndTypeIndex()
      Gets the reference (index) to signature of the field.
      Returns:
      Reference (index) to signature of the field.
    • setClassIndex

      public final void setClassIndex(int classIndex)
      Sets the class index.
      Parameters:
      classIndex - points to Constant_class.
    • setNameAndTypeIndex

      public final void setNameAndTypeIndex(int nameAndTypeIndex)
      Sets the name and type index.
      Parameters:
      nameAndTypeIndex - points to Constant_NameAndType.
    • toString

      public String toString()
      Overrides:
      toString in class Constant
      Returns:
      String representation. not final as ConstantInvokeDynamic needs to modify