APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.bcel.internal.classfile

public final Class Field

extends FieldOrMethod
Class Inheritance
Imports
java.io.DataInput, .IOException, java.util.Objects, com.sun.org.apache.bcel.internal.Const, com.sun.org.apache.bcel.internal.generic.Type, com.sun.org.apache.bcel.internal.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.

Inherited from com.sun.org.apache.bcel.internal.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 com.sun.org.apache.bcel.internal.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
copy(final ConstantPool constantPool)

Returns: deep copy of this field

public boolean
equals(final Object obj)

Overrides java.lang.Object.equals.

Return value as defined by given BCELComparator strategy.

public static BCELComparator<Field>
getComparator()

Returns: Comparison strategy object.

public ConstantValue
getConstantValue()

Returns: constant value associated with this field (may be null)

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 com.sun.org.apache.bcel.internal.classfile.FieldOrMethod:
copy_dumpgetAnnotationEntriesgetAttributegetAttributesgetConstantPoolgetGenericSignaturegetNamegetNameIndexgetSignaturegetSignatureIndexsetAttributessetConstantPoolsetNameIndexsetSignatureIndex

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

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 com.sun.org.apache.bcel.internal.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.

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.

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