# Class FieldGenOrMethodGen

java.lang.Object
org.apache.bcel.classfile.AccessFlags
org.apache.bcel.generic.FieldGenOrMethodGen

All Implemented Interfaces:
  `Cloneable, NamedAndTyped`

Direct Known Subclasses:
  `FieldGen, MethodGen`

public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAndTyped, Cloneable
Super class for FieldGen and MethodGen objects, since they have some methods in common!

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected ConstantPoolGen`
  `cp`
  Deprecated.
  (since 6.0) will be made private; do not access directly, use getter/setter
  `protected String`
  `name`
  Deprecated.
  (since 6.0) will be made private; do not access directly, use getter/setter
  `protected Type`
  `type`
  Deprecated.
  (since 6.0) will be made private; do not access directly, use getter/setter

  ### Fields inherited from class AccessFlags

  `access_flags`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `FieldGenOrMethodGen()`
  Constructs a FieldGenOrMethodGen.
  `protected`
  `FieldGenOrMethodGen(int accessFlags)`
  Constructs a FieldGenOrMethodGen.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `addAll(Attribute[] attributes)`
  Adds all attributes from an array.
  `void`
  `addAnnotationEntry(AnnotationEntryGen ag)`
  Adds an annotation entry.
  `void`
  `addAttribute(Attribute a)`
  Add an attribute to this method.
  `Object`
  `clone()`
  `AnnotationEntryGen[]`
  `getAnnotationEntries()`
  Gets all annotation entries.
  `Attribute[]`
  `getAttributes()`
  Gets all attributes of this method or field.
  `ConstantPoolGen`
  `getConstantPool()`
  Gets the constant pool.
  `String`
  `getName()`
  Gets the name.
  `abstract String`
  `getSignature()`
  Gets the signature of method or field.
  `Type`
  `getType()`
  Gets the type.
  `void`
  `removeAnnotationEntries()`
  Removes all annotation entries.
  `void`
  `removeAnnotationEntry(AnnotationEntryGen ag)`
  Removes an annotation entry.
  `void`
  `removeAttribute(Attribute a)`
  Removes an attribute.
  `void`
  `removeAttributes()`
  Removes all attributes.
  `void`
  `setConstantPool(ConstantPoolGen cp)`
  Sets the constant pool.
  `void`
  `setName(String name)`
  Sets the name.
  `void`
  `setType(Type type)`
  Sets the type.

  ### Methods inherited from class AccessFlags

  `getAccessFlags, getModifiers, isAbstract, isAbstract, isAnnotation, isAnnotation, isEnum, isEnum, isFinal, isFinal, isInterface, isInterface, isNative, isNative, isPrivate, isPrivate, isProtected, isProtected, isPublic, isPublic, isStatic, isStatic, isStrictfp, isStrictfp, isSynchronized, isSynchronized, isSynthetic, isSynthetic, isTransient, isTransient, isVarArgs, isVarArgs, isVolatile, isVolatile, setAccessFlags, setModifiers`

  ### Methods inherited from class Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### name

    @Deprecated protected String name
    Deprecated.
    (since 6.0) will be made private; do not access directly, use getter/setter

  - ### type

    @Deprecated protected Type type
    Deprecated.
    (since 6.0) will be made private; do not access directly, use getter/setter

  - ### cp

    @Deprecated protected ConstantPoolGen cp
    Deprecated.
    (since 6.0) will be made private; do not access directly, use getter/setter

- ## Constructor Details

  - ### FieldGenOrMethodGen

    protected FieldGenOrMethodGen()
    Constructs a FieldGenOrMethodGen.

  - ### FieldGenOrMethodGen

    protected FieldGenOrMethodGen(int accessFlags)
    Constructs a FieldGenOrMethodGen.
    Parameters:
      `accessFlags` - the access flags.
    Since:
      6.0

- ## Method Details

  - ### addAll

    protected void addAll(Attribute[] attributes)
    Adds all attributes from an array.
    Parameters:
      `attributes` - the attributes to add.

  - ### addAnnotationEntry

    public void addAnnotationEntry(AnnotationEntryGen ag)
    Adds an annotation entry.
    Parameters:
      `ag` - the annotation entry.
    Since:
      6.0

  - ### addAttribute

    public void addAttribute(Attribute a)
    Add an attribute to this method. Currently, the JVM knows about the 'Code', 'ConstantValue', 'Synthetic' and 'Exceptions' attributes. Other attributes will be ignored by the JVM but do no harm.
    Parameters:
      `a` - attribute to be added.

  - ### clone

    public Object clone()
    Overrides:
      `clone` in class `Object`

  - ### getAnnotationEntries

    public AnnotationEntryGen[] getAnnotationEntries()
    Gets all annotation entries.
    Returns:
      all annotation entries.

  - ### getAttributes

    public Attribute[] getAttributes()
    Gets all attributes of this method or field.
    Returns:
      all attributes of this method.

  - ### getConstantPool

    public ConstantPoolGen getConstantPool()
    Gets the constant pool.
    Returns:
      the constant pool.

  - ### getName

    public String getName()
    Description copied from interface: `NamedAndTyped`
    Gets the name.
    Specified by:
      `getName` in interface `NamedAndTyped`
    Returns:
      name of method/field.

  - ### getSignature

    public abstract String getSignature()
    Gets the signature of method or field.
    Returns:
      signature of method/field.

  - ### getType

    public Type getType()
    Description copied from interface: `NamedAndTyped`
    Gets the type.
    Specified by:
      `getType` in interface `NamedAndTyped`
    Returns:
      the type.

  - ### removeAnnotationEntries

    public void removeAnnotationEntries()
    Removes all annotation entries.
    Since:
      6.0

  - ### removeAnnotationEntry

    public void removeAnnotationEntry(AnnotationEntryGen ag)
    Removes an annotation entry.
    Parameters:
      `ag` - the annotation entry to remove.
    Since:
      6.0

  - ### removeAttribute

    public void removeAttribute(Attribute a)
    Removes an attribute.
    Parameters:
      `a` - the attribute to remove.

  - ### removeAttributes

    public void removeAttributes()
    Removes all attributes.

  - ### setConstantPool

    public void setConstantPool(ConstantPoolGen cp)
    Sets the constant pool.
    Parameters:
      `cp` - the constant pool.

  - ### setName

    public void setName(String name)
    Description copied from interface: `NamedAndTyped`
    Sets the name.
    Specified by:
      `setName` in interface `NamedAndTyped`
    Parameters:
      `name` - the name.

  - ### setType

    public void setType(Type type)
    Description copied from interface: `NamedAndTyped`
    Sets the type.
    Specified by:
      `setType` in interface `NamedAndTyped`
    Parameters:
      `type` - the type.