org.apache.bcel.generic

## 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 and 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 org.apache.bcel.classfile.AccessFlags

      `access_flags`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `FieldGenOrMethodGen()`
    `protected` | `FieldGenOrMethodGen(int access_flags)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addAnnotationEntry(AnnotationEntryGen ag)`
    `void` | `addAttribute(Attribute a)` Add an attribute to this method.
    `Object` | `clone()`
    `AnnotationEntryGen[]` | `getAnnotationEntries()`
    `Attribute[]` | `getAttributes()`
    `ConstantPoolGen` | `getConstantPool()`
    `String` | `getName()`
    `abstract String` | `getSignature()`
    `Type` | `getType()`
    `protected void` | `removeAnnotationEntries()`
    `protected void` | `removeAnnotationEntry(AnnotationEntryGen ag)`
    `void` | `removeAttribute(Attribute a)` Remove an attribute.
    `void` | `removeAttributes()` Remove all attributes.
    `void` | `setConstantPool(ConstantPoolGen cp)`
    `void` | `setName(String name)`
    `void` | `setType(Type type)`

    - ### Methods inherited from class org.apache.bcel.classfile.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 java.lang.Object

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

- - ### Field Detail

    - #### 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 Detail

    - #### FieldGenOrMethodGen

          protected FieldGenOrMethodGen()

    - #### FieldGenOrMethodGen

          protected FieldGenOrMethodGen(int access_flags)

      Since:
        6.0

  - ### Method Detail

    - #### setType

          public void setType(Type type)

      Specified by:
        `setType` in interface `NamedAndTyped`

    - #### getType

          public Type getType()

      Specified by:
        `getType` in interface `NamedAndTyped`

    - #### getName

          public String getName()

      Specified by:
        `getName` in interface `NamedAndTyped`
      Returns:
        name of method/field.

    - #### setName

          public void setName(String name)

      Specified by:
        `setName` in interface `NamedAndTyped`

    - #### getConstantPool

          public ConstantPoolGen getConstantPool()

    - #### setConstantPool

          public void setConstantPool(ConstantPoolGen cp)

    - #### 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

    - #### addAnnotationEntry

          protected void addAnnotationEntry(AnnotationEntryGen ag)

      Since:
        6.0

    - #### removeAttribute

          public void removeAttribute(Attribute a)

      Remove an attribute.

    - #### removeAnnotationEntry

          protected void removeAnnotationEntry(AnnotationEntryGen ag)

      Since:
        6.0

    - #### removeAttributes

          public void removeAttributes()

      Remove all attributes.

    - #### removeAnnotationEntries

          protected void removeAnnotationEntries()

      Since:
        6.0

    - #### getAttributes

          public Attribute[] getAttributes()

      Returns:
        all attributes of this method.

    - #### getAnnotationEntries

          public AnnotationEntryGen[] getAnnotationEntries()

    - #### getSignature

          public abstract String getSignature()

      Returns:
        signature of method/field.

    - #### clone

          public Object clone()

      Overrides:
        `clone` in class `Object`

Copyright © 2004–2019 The Apache Software Foundation. All rights reserved.