Field provides information about, and dynamic access to, a
single field of a class or an interface. The reflected field may
be a class (static) field or an instance field.
A Field permits widening conversions to occur during a get or
set access operation, but throws an IllegalArgumentException if a
narrowing conversion would occur.
Member, java.lang.Class , java.lang.Class#getFields() , java.lang.Class#getField(String) , java.lang.Class#getDeclaredFields() , java.lang.Class#getDeclaredField(String)
| Modifier and Type | Class and Description |
|---|---|
| private static interface | Field.
A function that sets a field to a value. |
| Modifier and Type | Field and Description |
|---|---|
| private final byte[] | |
| private final Class | |
| private transient volatile Map | |
| private FieldAccessor | |
| private transient volatile FieldRepository | |
| private final int | |
| private final String | |
| private FieldAccessor | |
| private Field | root
Fields are mutable due to |
| private final transient String | |
| private final int | |
| private final boolean | |
| private final Class |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Set | Returns: an unmodifiable set of the access flags for this field, possibly emptyOverrides default java. Returns an unmodifiable set of the access flags for this field, possibly empty. |
| private FieldAccessor | |
| private FieldAccessor | |
| private String | callerNotAllowedToMutateMessage(Class<?> caller, boolean unreflect)
Returns the exception message for the IllegalAccessException when this final field cannot be mutated because the caller module is not allowed to mutate final fields. |
| private String | cannotSetFieldMessage(Class<?> caller, boolean unreflect)
Returns a message to indicate that the caller cannot set/unreflect this final field. |
| private String | cannotSetFieldMessage(String prefix, boolean unreflect)
Returns a message to indicate that a field cannot be set/unreflected. |
| private void | |
| pack-priv void | checkAllowedToUnreflectFinalSetter(Class<?> caller)
Check that the caller is allowed to unreflect for mutation a final instance field in a normal class. |
| pack-priv void | checkCanSetAccessible(Class<?> caller)
Overrides java. If the given AccessibleObject is a |
| pack-priv Field | copy()
Package-private routine (exposed to java.lang.Class via ReflectAccess) which returns a copy of this Field. |
| private Map | |
| public boolean | equals(Object obj)
Overrides java. Compares this |
| private String | finalFieldMutationWarning(Class<?> caller, boolean unreflect)
Returns the warning message to print when this final field is mutated by the given possibly-null caller. |
| public Object | |
| public AnnotatedType | Returns: an object representing the declared type of the field represented by this FieldReturns an AnnotatedType object that represents the use of a type to specify the declared type of the field represented by this Field. |
| public <T extends Annotation> T | getAnnotation(Class<T> annotationClass)
Overrides java. Implements java. Returns this element's annotation for the specified type if such an annotation is present, else null. |
| public <T extends Annotation> T[] | getAnnotationsByType(Class<T> annotationClass)
Overrides java. Overrides default java. Returns annotations that are associated with this element. |
| public boolean | Returns: the value of theboolean fieldthe object to extract the obj)boolean value
fromGets the value of a static or instance |
| public byte | |
| public char | |
| public Annotation[] | getDeclaredAnnotations()
Overrides java. Implements java. Returns annotations that are directly present on this element. |
| public Class | getDeclaringClass()
Implements java. Returns the |
| public double | |
| private GenericsFactory | |
| private FieldAccessor | |
| public float | |
| private FieldRepository | |
| private String | |
| public Type | Returns: aType object that represents the declared type for
the field represented by this Field objectReturns a |
| public int | |
| public long | |
| public int | getModifiers()
Implements java. Returns the Java language modifiers for the field represented
by this |
| public String | getName()
Implements java. Returns the name of the field represented by this |
| private FieldAccessor | |
| pack-priv Field | getRoot()
Overrides java. Returns the root AccessibleObject; or null if this object is the root. |
| public short | |
| public Class | Returns: aClass object identifying the declared
type of the field represented by this objectReturns a |
| private native byte[] | |
| public int | |
| public boolean | Returns: true if and only if this field represents an element of
an enumerated class.Returns |
| private boolean | isFinalDeeplyAccessible(Class<?> caller)
Returns true if this final field is "deeply accessible" to the caller. |
| private boolean | isFinalInstanceInNormalClass()
Return true if this field is a final instance field in a normal class (not a record class or hidden class), |
| public boolean | Returns: true if and only if this field is a synthetic field as defined by the Java Language Specification.Implements java. Returns |
| pack-priv boolean | |
| private String | |
| private Module | |
| private String | notAccessibleToCallerMessage(Class<?> caller, boolean unreflect)
Returns the message for an IllegalAccessException when a final field cannot be mutated because the declaring class is in a package that is not "deeply accessible" to the caller. |
| private String | notAccessibleToNoCallerMessage(boolean unreflect)
Returns the message for an IllegalAccessException when a field is not accessible to a JNI attached thread. |
| private void | postSetFinal(Class<?> caller, boolean unreflect)
Invoke after mutating a final instance field, or when unreflecting a final instance field for mutation, to print a warning and record a JFR event. |
| private void | preSetFinal(Class<?> caller, boolean unreflect)
Invoke before attempting to mutate, or unreflect for mutation, a final instance field in a normal class. |
| public void | |
| public void | setAccessible(boolean flag)
Overrides java. Set the |
| public void | setBoolean(Object
the object whose field should be modified obj, boolean the new value for the field of z)obj
being modifiedSets the value of a field as a |
| public void | |
| public void | |
| public void | |
| private void | |
| private void | |
| public void | |
| public void | |
| public void | |
| private void | |
| public void | |
| public String | Returns: a string describing thisField, including
its generic typeReturns a string describing this |
| pack-priv String | toShortString()
Overrides java. Returns a short descriptive string to describe this object in log messages. |
| public String | Returns: a string describing thisFieldOverrides java. Returns a string describing this |