Class FieldOrMethod

java.lang.Object
org.apache.bcel.classfile.AccessFlags
org.apache.bcel.classfile.FieldOrMethod
All Implemented Interfaces:
Cloneable, Node
Direct Known Subclasses:
Field, Method

public abstract class FieldOrMethod extends AccessFlags implements Cloneable, Node
Abstract super class for fields and methods.
  • Field Details

    • name_index

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

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

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

      Deprecated.
      (since 6.0) will be removed (not needed)
    • constant_pool

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

    • FieldOrMethod

      protected FieldOrMethod(DataInput file, ConstantPool constantPool) throws IOException
      Constructs object from file stream.
      Parameters:
      file - Input stream.
      constantPool - the constant pool.
      Throws:
      IOException - if an I/O error occurs.
    • FieldOrMethod

      @Deprecated protected FieldOrMethod(DataInputStream file, ConstantPool constantPool) throws IOException
      Deprecated.
      Constructs object from file stream.
      Parameters:
      file - Input stream.
      constantPool - the constant pool.
      Throws:
      IOException - if an I/O error occurs.
    • FieldOrMethod

      Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical copy.
      Parameters:
      c - Source to copy.
    • FieldOrMethod

      protected FieldOrMethod(int accessFlags, int nameIndex, int signatureIndex, Attribute[] attributes, ConstantPool constantPool)
      Constructs a FieldOrMethod.
      Parameters:
      accessFlags - Access rights of method.
      nameIndex - Points to field name in constant pool.
      signatureIndex - Points to encoded signature.
      attributes - Collection of attributes.
      constantPool - Array of constants.
  • Method Details

    • copy_

      protected FieldOrMethod copy_(ConstantPool constantPool)
      Creates a deep copy of this field.
      Parameters:
      constantPool - the constant pool.
      Returns:
      deep copy of this field.
    • dump

      public final void dump(DataOutputStream file) throws IOException
      Dumps object to file stream on binary format.
      Parameters:
      file - Output file stream.
      Throws:
      IOException - if an I/O error occurs.
    • getAnnotationEntries

      Gets annotations on the field or method.
      Returns:
      Annotations on the field or method.
      Since:
      6.0
    • getAttribute

      public final <T extends Attribute> T getAttribute(byte tag)
      Gets attribute for given tag.
      Type Parameters:
      T - the attribute type.
      Parameters:
      tag - the attribute tag.
      Returns:
      Attribute for given tag, null if not found. Refer to Const.ATTR_UNKNOWN constants named ATTR_* for possible values.
      Since:
      6.10.0
    • getAttributes

      public final Attribute[] getAttributes()
      Gets the collection of object attributes.
      Returns:
      Collection of object attributes.
    • getConstantPool

      public final ConstantPool getConstantPool()
      Gets the constant pool used by this object.
      Returns:
      Constant pool used by this object.
    • getGenericSignature

      public final String getGenericSignature()
      Hunts for a signature attribute on the member and returns its contents. So where the 'regular' signature may be (Ljava/util/Vector;)V the signature attribute may in fact say 'Ljava/lang/Vector<Ljava/lang/String>;' Coded for performance - searches for the attribute only when requested - only searches for it once.
      Returns:
      the generic signature.
      Since:
      6.0
    • getName

      public final String getName()
      Gets the name of object.
      Returns:
      Name of object, that is, method name or field name.
    • getNameIndex

      public final int getNameIndex()
      Gets the index in constant pool of object's name.
      Returns:
      Index in constant pool of object's name.
    • getSignature

      public final String getSignature()
      Gets the string representation of object's type signature.
      Returns:
      String representation of object's type signature (Java style).
    • getSignatureIndex

      public final int getSignatureIndex()
      Gets the index in constant pool of field signature.
      Returns:
      Index in constant pool of field signature.
    • setAttributes

      public final void setAttributes(Attribute[] attributes)
      Sets the collection of object attributes.
      Parameters:
      attributes - Collection of object attributes.
    • setConstantPool

      public final void setConstantPool(ConstantPool constantPool)
      Sets the constant pool to be used for this object.
      Parameters:
      constantPool - Constant pool to be used for this object.
    • setNameIndex

      public final void setNameIndex(int nameIndex)
      Sets the index in constant pool of object's name.
      Parameters:
      nameIndex - Index in constant pool of object's name.
    • setSignatureIndex

      public final void setSignatureIndex(int signatureIndex)
      Sets the index in constant pool of field signature.
      Parameters:
      signatureIndex - Index in constant pool of field signature.