Module java.base
Package java.lang.reflect

# Class Field

≠
public final class Field
extends java.lang.reflect.AccessibleObject
implements java.lang.reflect.Member

## Methods

- ≠
  public java.util.Set<java.lang.reflect.AccessFlag> accessFlags()
  Comparing jdk-master and valhalla-csr-open

  ### accessFlags

  public Set<AccessFlag> accessFlags()
  Returns an unmodifiable set of the access flags for this field, possibly empty. The `AccessFlags` may depend on the class file format version of the class.
  Specified by:
    `accessFlags` in interface `Member`
  Returns:
    an unmodifiable set of the access flags for this field, possibly empty
  See Java Virtual Machine Specification:
    4.5 Fields
  Since:
    20
  See Also:
    - `getModifiers()`
- =
  public boolean equals(java.lang.Object arg0)
- =
  public java.lang.Object get(java.lang.Object arg0) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public java.lang.reflect.AnnotatedType getAnnotatedType()
- =
  public <T> T getAnnotation(java.lang.Class<T> arg0)
- =
  public <T> T[] getAnnotationsByType(java.lang.Class<T> arg0)
- =
  public boolean getBoolean(java.lang.Object arg0) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public byte getByte(java.lang.Object arg0) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public char getChar(java.lang.Object arg0) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public java.lang.annotation.Annotation[] getDeclaredAnnotations()
- =
  public java.lang.Class<?> getDeclaringClass()
- =
  public double getDouble(java.lang.Object arg0) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public float getFloat(java.lang.Object arg0) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public java.lang.reflect.Type getGenericType()
- =
  public int getInt(java.lang.Object arg0) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public long getLong(java.lang.Object arg0) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public int getModifiers()
- =
  public java.lang.String getName()
- =
  public short getShort(java.lang.Object arg0) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public java.lang.Class<?> getType()
- =
  public int hashCode()
- =
  public boolean isEnumConstant()
- +Only in: valhalla-csr-open; not in: jdk-master.
  public boolean isStrictInit()
  Not in jdk-master; only in valhalla-csr-open

  ### isStrictInit

  public boolean isStrictInit()
  `isStrictInit` is a reflective preview API of the Java platform.
  Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
  Returns `true` if this field is a strictly initialized field; returns `false` otherwise.
  Returns:
    true if and only if this field is a strictly initialized field as defined by the Java Virtual Machine Specification
  See Java Virtual Machine Specification:
    4.5 Field access and property flagsPREVIEW
  Since:
    Valhalla
- =
  public boolean isSynthetic()
- ≠
  public void set(java.lang.Object arg0, java.lang.Object arg1) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
  Comparing jdk-master and valhalla-csr-open

  ### set

  public void set (Object obj, Object value) throws IllegalArgumentException, IllegalAccessException
  Sets the field represented by this `Field` object on the specified object argument to the specified new value. The new value is automatically unwrapped if the underlying field has a primitive type.

  The operation proceeds as follows:

  If the underlying field is static, the `obj` argument is ignored; it may be null.

  Otherwise the underlying field is an instance field. If the specified object argument is null, the method throws a `NullPointerException` . If the specified object argument is not an instance of the class or interface declaring the underlying field, the method throws an `IllegalArgumentException` .

  If this `Field` object is enforcing Java language access control, and the underlying field is inaccessible, the method throws an `IllegalAccessException` .

  If the underlying field is final, this `Field` object has write access if and only if all of the following conditions are true, where `D` is the field's declaring class:

  - `setAccessible(true)` has succeeded for this `Field` object.
  - final field mutation is enabled for the caller's module.
  - At least one of the following conditions holds:
    1. `D` and the caller class are in the same module.
    2. The field is `public` and `D` is `public` in a package that the module containing `D` exports to at least the caller's module.
    3. `D` is in a package that is open to the caller's module.
  - `D` is not a record class.
  - `D` is not a hidden class.
  - `D` is not a value classPREVIEW .
  - The field is non-static.

  If any of the above conditions is not met, this method throws an `IllegalAccessException` .

  These conditions are more restrictive than the conditions specified by `setAccessible(boolean)` to suppress access checks. In particular, updating a module to export or open a package cannot be used to allow write access to final fields with the `set` methods defined by `Field` . Condition (b) is not met if the module containing `D` has been updated with addExports to export the package to the caller's module. Condition (c) is not met if the module containing `D` has been updated with addOpens to open the package to the caller's module.

  This method may be called by JNI code with no caller class on the stack. In that case, and when the underlying field is final, this `Field` object has write access if and only if all of the following conditions are true, where `D` is the field's declaring class:

  - `setAccessible(true)` has succeeded for this `Field` object.
  - final field mutation is enabled for the unnamed module.
  - The field is `public` and `D` is `public` in a package that is exported to all modules.
  - `D` is not a record class.
  - `D` is not a hidden class.
  - The field is non-static.

  If any of the above conditions is not met, this method throws an `IllegalAccessException` .

  Setting a final field in this way is meaningful only during deserialization or reconstruction of instances of classes with blank final fields, before they are made available for access by other parts of a program. Use in any other context may have unpredictable effects, including cases in which other parts of a program continue to use the original value of this field.

  If the underlying field is of a primitive type, an unwrapping conversion is attempted to convert the new value to a value of a primitive type. If this attempt fails, the method throws an `IllegalArgumentException` .

  If, after possible unwrapping, the new value cannot be converted to the type of the underlying field by an identity or widening conversion, the method throws an `IllegalArgumentException` .

  If the underlying field is static, the class that declared the field is initialized if it has not already been initialized.

  The field is set to the possibly unwrapped and widened new value.

  If the field is hidden in the type of `obj` , the field's value is set according to the preceding rules.

  Parameters:
    `obj` - the object whose field should be modified
    `value` - the new value for the field of `obj` being modified
  Throws:
    `IllegalAccessException` - if this `Field` object is enforcing Java language access control and the underlying field is inaccessible or final; or if this `Field` object has no write access.
    `IllegalArgumentException` - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if an unwrapping conversion fails.
    `NullPointerException` - if the specified object is null and the field is an instance field.
    `ExceptionInInitializerError` - if the initialization provoked by this method fails.
  See Also:
    - Mutation methods
- =
  public void setAccessible(boolean arg0)
- =
  public void setBoolean(java.lang.Object arg0, boolean arg1) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public void setByte(java.lang.Object arg0, byte arg1) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public void setChar(java.lang.Object arg0, char arg1) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public void setDouble(java.lang.Object arg0, double arg1) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public void setFloat(java.lang.Object arg0, float arg1) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public void setInt(java.lang.Object arg0, int arg1) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public void setLong(java.lang.Object arg0, long arg1) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public void setShort(java.lang.Object arg0, short arg1) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException
- =
  public java.lang.String toGenericString()
- =
  public java.lang.String toString()

## Summary

Differences
| Elements | Comments | Descriptions | Total
Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed
--- | --- | --- | --- | --- | --- | --- | --- | ---
accessFlags() |  |  |  |  |  |  | 2 |  |  | 2
isStrictInit() | 1 |  |  |  |  |  | 1 |  |  | 2
set(Object,Object) |  |  |  |  |  |  | 4 |  |  | 4
Total | 1 |  |  |  |  |  | 7 |  |  | 8