Top Description Fields Constructors Methods
org.apache.bcel.classfile

public final Class Field

extends FieldOrMethod
Class Inheritance
Imports
java.io.DataInput, .IOException, java.util.Objects, org.apache.bcel.Const, org.apache.bcel.generic.Type, org.apache.bcel.util.BCELComparator

This class represents the field info structure, i.e., the representation for a variable in the class. See JVM specification for details.

Field Summary

Modifier and TypeField and Description
private static BCELComparator<Field>
public static final Field[]
EMPTY_ARRAY

Empty array constant.

pack-priv static final Field[]
EMPTY_FIELD_ARRAY

Empty array.

Inherited from org.apache.bcel.classfile.FieldOrMethod:
attributesattributes_countconstant_poolname_indexsignature_index

Constructor Summary

AccessConstructor and Description
pack-priv
Field(final DataInput
Input stream.
file
,
final ConstantPool constantPool)

Constructs object from file stream.

public
Field(final Field
Source to copy.
c
)

Initialize from another object.

public
Field(final int
Access rights of field
accessFlags
,
final int
Points to field name in constant pool
nameIndex
,
final int
Points to encoded signature
signatureIndex
,
final Attribute[]
Collection of attributes
attributes
,
final ConstantPool
Array of constants
constantPool
)

Method Summary

Modifier and TypeMethod and Description
public void
accept(final Visitor
Visitor object
v
)

Implements org.apache.bcel.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
public Field

Returns:

deep copy of this field
copy
(final ConstantPool constantPool)

public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Return value as defined by given BCELComparator strategy.
public static BCELComparator<Field>

Returns:

Comparison strategy object.
getComparator
()

public ConstantValue

Returns:

constant value associated with this field (may be null)
getConstantValue
()

public Type

Returns:

type of field
getType
()

See https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.2.2

public int
hashCode()

Overrides java.lang.Object.hashCode.

Return value as defined by given BCELComparator strategy.
public static void
setComparator(final BCELComparator<Field>
Comparison strategy object.
comparator
)

public String

Returns:

String representation of field, including the signature.
toString
()

Overrides java.lang.Object.toString.

Return string representation close to declaration format, 'public static final short MAX = 100', e.g..
Inherited from org.apache.bcel.classfile.FieldOrMethod:
copy_dumpgetAnnotationEntriesgetAttributesgetConstantPoolgetGenericSignaturegetNamegetNameIndexgetSignaturegetSignatureIndexsetAttributessetConstantPoolsetNameIndexsetSignatureIndex

Field Detail

bcelComparatorback to summary
private static BCELComparator<Field> bcelComparator
EMPTY_ARRAYback to summary
public static final Field[] EMPTY_ARRAY

Empty array constant.

Since
6.6.0
EMPTY_FIELD_ARRAYback to summary
pack-priv static final Field[] EMPTY_FIELD_ARRAY

Empty array.

Constructor Detail

Fieldback to summary
pack-priv Field(final DataInput file, final ConstantPool constantPool) throws IOException, ClassFormatException

Constructs object from file stream.

Parameters
file:DataInput

Input stream.

Fieldback to summary
public Field(final Field c)

Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical copy.

Parameters
c:Field

Source to copy.

Fieldback to summary
public Field(final int accessFlags, final int nameIndex, final int signatureIndex, final Attribute[] attributes, final ConstantPool constantPool)
Parameters
accessFlags:int

Access rights of field

nameIndex:int

Points to field name in constant pool

signatureIndex:int

Points to encoded signature

attributes:Attribute[]

Collection of attributes

constantPool:ConstantPool

Array of constants

Method Detail

acceptback to summary
public void accept(final Visitor v)

Implements org.apache.bcel.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.

Parameters
v:Visitor

Visitor object

Annotations
@Override
copyback to summary
public Field copy(final ConstantPool constantPool)
Returns:Field

deep copy of this field

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Return value as defined by given BCELComparator strategy. By default two Field objects are said to be equal when their names and signatures are equal.

Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
See Also
Object#equals(Object)
getComparatorback to summary
public static BCELComparator<Field> getComparator()
Returns:BCELComparator<Field>

Comparison strategy object.

getConstantValueback to summary
public ConstantValue getConstantValue()
Returns:ConstantValue

constant value associated with this field (may be null)

getTypeback to summary
public Type getType()

See https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.2.2

Returns:Type

type of field

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Return value as defined by given BCELComparator strategy. By default return the hash code of the field's name XOR signature.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

Annotations
@Override
See Also
Object#hashCode()
setComparatorback to summary
public static void setComparator(final BCELComparator<Field> comparator)
Parameters
comparator:BCELComparator<Field>

Comparison strategy object.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return string representation close to declaration format, 'public static final short MAX = 100', e.g..

Returns:String

String representation of field, including the signature.

Annotations
@Override