Class FieldOrMethod
java.lang.Object
org.apache.bcel.classfile.AccessFlags
org.apache.bcel.classfile.FieldOrMethod
Abstract superclass for fields and methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Attribute[]Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter.protected intDeprecated.(since 6.0) will be removed (not needed)protected ConstantPoolDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter.protected intDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter.protected intDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter.Fields inherited from class AccessFlags
access_flagsModifier and TypeFieldDescriptionprotected intDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFieldOrMethod(int accessFlags, int nameIndex, int signatureIndex, Attribute[] attributes, ConstantPool constantPool) Constructs a FieldOrMethod.protectedFieldOrMethod(DataInput file, ConstantPool constantPool) Constructs a field or method from a data input using standard Code headers.protectedFieldOrMethod(DataInputStream file, ConstantPool constantPool) Deprecated.(6.0) UseFieldOrMethod(java.io.DataInput, ConstantPool)instead.protectedInitialize from another object. -
Method Summary
Modifier and TypeMethodDescriptionprotected FieldOrMethodcopy_(ConstantPool constantPool) Creates a deep copy of this field.final voiddump(DataOutputStream file) Dumps object to file stream on binary format.Gets annotations on the field or method.final <T extends Attribute>
TgetAttribute(byte tag) Gets attribute for given tag.final Attribute[]Gets the collection of object attributes.final ConstantPoolGets the constant pool used by this object.final StringGets the contents of the signature attribute on this member.final StringgetName()Gets the name of object.final intGets the index in constant pool of object's name.final StringGets the string representation of object's type signature.final intGets the index in constant pool of field signature.final voidsetAttributes(Attribute[] attributes) Sets the collection of object attributes.final voidsetConstantPool(ConstantPool constantPool) Sets the constant pool to be used for this object.final voidsetNameIndex(int nameIndex) Sets the index in constant pool of object's name.final voidsetSignatureIndex(int signatureIndex) Sets the index in constant pool of field signature.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, setModifiersModifier and TypeMethodDescriptionfinal intGets access flags.final intGets access flags.final booleanTests whether the abstract bit is on.final voidisAbstract(boolean flag) Sets the abstract bit.final booleanTests whether the annotation bit is on.final voidisAnnotation(boolean flag) Sets the annotation bit.final booleanisEnum()Tests whether the enum bit is on.final voidisEnum(boolean flag) Sets the enum bit.final booleanisFinal()Tests whether the final bit is on.final voidisFinal(boolean flag) Sets the final bit.final booleanTests whether the interface bit is on.final voidisInterface(boolean flag) Sets the interface bit.final booleanisNative()Tests whether the native bit is on.final voidisNative(boolean flag) Sets the native bit.final booleanTests whether the private bit is on.final voidisPrivate(boolean flag) Sets the private bit.final booleanTests whether the protected bit is on.final voidisProtected(boolean flag) Sets the protected bit.final booleanisPublic()Tests whether the public bit is on.final voidisPublic(boolean flag) Sets the public bit.final booleanisStatic()Tests whether the static bit is on.final voidisStatic(boolean flag) Sets the static bit.final booleanTests whether the strict bit is on.final voidisStrictfp(boolean flag) Sets the strict bit.final booleanTests whether the synchronized bit is on.final voidisSynchronized(boolean flag) Sets the synchronized bit.final booleanTests whether the synthetic bit is on.final voidisSynthetic(boolean flag) Sets the synthetic bit.final booleanTests whether the transient bit is on.final voidisTransient(boolean flag) Sets the transient bit.final booleanTests whether the varargs bit is on.final voidisVarArgs(boolean flag) Sets the varargs bit.final booleanTests whether the volatile bit is on.final voidisVolatile(boolean flag) Sets the volatile bit.final voidsetAccessFlags(int accessFlags) Sets access flags also known as modifiers.final voidsetModifiers(int accessFlags) Sets access flags aka "modifiers".
-
Field Details
-
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
Constructs a field or method from a data input using standard Code headers.- Parameters:
file- Input stream.constantPool- The constant pool.- Throws:
IOException- Thrown if an I/O error occurs.ClassFormatException- Thrown if the field or method, or one of its attributes, is malformed.
-
FieldOrMethod
@Deprecated protected FieldOrMethod(DataInputStream file, ConstantPool constantPool) throws IOException Deprecated.(6.0) UseFieldOrMethod(java.io.DataInput, ConstantPool)instead.Constructs a field or method from a data input stream using standard Code headers.- Parameters:
file- Input stream.constantPool- The constant pool.- Throws:
IOException- Thrown if an I/O error occurs.ClassFormatException- Thrown if the field or method, or one of its attributes, is malformed.
-
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 the field or method.nameIndex- Points to the field or method name in the constant pool.signatureIndex- Points to encoded signature.attributes- Collection of attributes.constantPool- Array of constants.
-
-
Method Details
-
copy_
Creates a deep copy of this field.- Parameters:
constantPool- The constant pool.- Returns:
- deep copy of this field.
-
dump
Dumps object to file stream on binary format.- Parameters:
file- Output file stream.- Throws:
IOException- Thrown 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
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_UNKNOWNconstants named ATTR_* for possible values. - Since:
- 6.10.0
-
getAttributes
Gets the collection of object attributes.- Returns:
- Collection of object attributes.
-
getConstantPool
Gets the constant pool used by this object.- Returns:
- Constant pool used by this object.
-
getGenericSignature
Gets the contents of the signature attribute on this member. 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
-
getNameIndex
Gets the index in constant pool of object's name.- Returns:
- Index in constant pool of object's name.
-
getSignature
Gets the string representation of object's type signature.- Returns:
- String representation of object's type signature (Java style).
-
getSignatureIndex
Gets the index in constant pool of field signature.- Returns:
- Index in constant pool of field signature.
-
setAttributes
Sets the collection of object attributes.- Parameters:
attributes- Collection of object attributes.
-
setConstantPool
Sets the constant pool to be used for this object.- Parameters:
constantPool- Constant pool to be used for this object.
-
setNameIndex
Sets the index in constant pool of object's name.- Parameters:
nameIndex- Index in constant pool of object's name.
-
setSignatureIndex
Sets the index in constant pool of field signature.- Parameters:
signatureIndex- Index in constant pool of field signature.
-