Field (Java SE 19 & JDK 19) (original) (raw)
All Superinterfaces:
[Accessible](Accessible.html "interface in com.sun.jdi")
, [Comparable](../../../../java.base/java/lang/Comparable.html "interface in java.lang")<[Field](Field.html "interface in com.sun.jdi")>
, [Mirror](Mirror.html "interface in com.sun.jdi")
, [TypeComponent](TypeComponent.html "interface in com.sun.jdi")
A class or instance variable in the target VM. See TypeComponent for general information about Field and Method mirrors.
Since:
1.3
See Also:
Method Summary
boolean
Compares the specified Object with this field for equality.int
[hashCode](#hashCode%28%29)()
Returns the hash code value for this Field.boolean
Determine if this is a field that represents an enum constant.boolean
Determine if this is a transient field.boolean
Determine if this is a volatile field.[type](#type%28%29)()
Returns the type of this field.[typeName](#typeName%28%29)()
Returns a text representation of the type of this field.
Method Details
typeName
Returns a text representation of the type of this field. Where the type is the type specified in the declaration of this field.
This type name is always available even if the type has not yet been created or loaded.
Returns:
a String representing the type of this field.type
Returns the type of this field. Where the type is the type specified in the declaration of this field.
For example, if a target class defines:
short s;
Date d;
byte[] ba;
And the JDI client defines theseField
objects:
Field sField = targetClass.fieldByName("s");
Field dField = targetClass.fieldByName("d");
Field baField = targetClass.fieldByName("ba");
to mirror the corresponding fields, thensField.type()
is a ShortType,dField.type()
is theReferenceType forjava.util.Date
and((ArrayType)(baField.type())).componentType()
is aByteType.
Note: if the type of this field is a reference type (class, interface, or array) and it has not been created or loaded by the declaring type's class loader - that is,declaringType().classLoader()
, then ClassNotLoadedException will be thrown. Also, a reference type may have been loaded but not yet prepared, in which case the type will be returned but attempts to perform some operations on the returned type (e.g. fields()) will throw a ClassNotPreparedException. Use ReferenceType.isPrepared() to determine if a reference type is prepared.
Returns:
the Type of this field.
Throws:
[ClassNotLoadedException](ClassNotLoadedException.html "class in com.sun.jdi")
- if the type has not yet been loaded or created through the appropriate class loader.
See Also:
* TypeisTransient
boolean isTransient()
Determine if this is a transient field.
Returns:
true
if this field is transient;false
otherwise.isVolatile
boolean isVolatile()
Determine if this is a volatile field.
Returns:
true
if this field is volatile;false
otherwise.isEnumConstant
boolean isEnumConstant()
Determine if this is a field that represents an enum constant.
Returns:
true
if this field represents an enum constant;false
otherwise.equals
boolean equals(Object obj)
Compares the specified Object with this field for equality.
Overrides:
[equals](../../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29)
in class[Object](../../../../java.base/java/lang/Object.html "class in java.lang")
Parameters:
obj
- the reference object with which to compare.
Returns:
true
if the Object is a Field and if both mirror the same field (declared in the same class or interface, in the same VM).
See Also:
* Object.hashCode()
* HashMaphashCode
int hashCode()
Returns the hash code value for this Field.
Overrides:
[hashCode](../../../../java.base/java/lang/Object.html#hashCode%28%29)
in class[Object](../../../../java.base/java/lang/Object.html "class in java.lang")
Returns:
the integer hash code.
See Also:
* Object.equals(java.lang.Object)
* System.identityHashCode(java.lang.Object)