< prev index next >
src/java.base/share/classes/java/lang/reflect/Field.java
Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com
@@ -719,14 +719,23 @@
*
* <p>If this {@code Field} object is enforcing Java language access control, and
* the underlying field is inaccessible, the method throws an
* {@code IllegalAccessException}.
*
- * <p>If the underlying field is final, the method throws an
- * {@code IllegalAccessException} unless {@code setAccessible(true)}
- * has succeeded for this {@code Field} object
- * and the field is non-static. Setting a final field in this way
+ * <p>If the underlying field is final, this {@code Field} object has
+ * <em>write</em> access if and only if the following conditions are met:
+ * <ul>
+ * <li>{@link #setAccessible(boolean) setAccessible(true)} has succeeded for
+ * this {@code Field} object;</li>
+ * <li>the field is non-static; and</li>
+ * <li>the field's declaring class is not a {@linkplain Class#isHiddenClass()
+ * hidden class}.</li>
+ * </ul>
+ * If any of the above checks is not met, this method throws an
+ * {@code IllegalAccessException}.
+ *
+ * <p> 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
@@ -754,11 +763,12 @@
* @param value the new value for the field of {@code obj}
* being modified
*
* @throws IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
- * field is either inaccessible or final.
+ * field is inaccessible or final;
+ * or if this {@code Field} object has no write access.
* @throws 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.
* @throws NullPointerException if the specified object is null
@@ -789,11 +799,12 @@
* @param z the new value for the field of {@code obj}
* being modified
*
* @throws IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
- * field is either inaccessible or final.
+ * field is either inaccessible or final;
+ * or if this {@code Field} object has no write access.
* @throws 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.
* @throws NullPointerException if the specified object is null
@@ -825,11 +836,12 @@
* @param b the new value for the field of {@code obj}
* being modified
*
* @throws IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
- * field is either inaccessible or final.
+ * field is either inaccessible or final;
+ * or if this {@code Field} object has no write access.
* @throws 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.
* @throws NullPointerException if the specified object is null
@@ -861,11 +873,12 @@
* @param c the new value for the field of {@code obj}
* being modified
*
* @throws IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
- * field is either inaccessible or final.
+ * field is either inaccessible or final;
+ * or if this {@code Field} object has no write access.
* @throws 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.
* @throws NullPointerException if the specified object is null
@@ -897,11 +910,12 @@
* @param s the new value for the field of {@code obj}
* being modified
*
* @throws IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
- * field is either inaccessible or final.
+ * field is either inaccessible or final;
+ * or if this {@code Field} object has no write access.
* @throws 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.
* @throws NullPointerException if the specified object is null
@@ -933,11 +947,12 @@
* @param i the new value for the field of {@code obj}
* being modified
*
* @throws IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
- * field is either inaccessible or final.
+ * field is either inaccessible or final;
+ * or if this {@code Field} object has no write access.
* @throws 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.
* @throws NullPointerException if the specified object is null
@@ -969,11 +984,12 @@
* @param l the new value for the field of {@code obj}
* being modified
*
* @throws IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
- * field is either inaccessible or final.
+ * field is either inaccessible or final;
+ * or if this {@code Field} object has no write access.
* @throws 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.
* @throws NullPointerException if the specified object is null
@@ -1005,11 +1021,12 @@
* @param f the new value for the field of {@code obj}
* being modified
*
* @throws IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
- * field is either inaccessible or final.
+ * field is either inaccessible or final;
+ * or if this {@code Field} object has no write access.
* @throws 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.
* @throws NullPointerException if the specified object is null
@@ -1041,11 +1058,12 @@
* @param d the new value for the field of {@code obj}
* being modified
*
* @throws IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
- * field is either inaccessible or final.
+ * field is either inaccessible or final;
+ * or if this {@code Field} object has no write access.
* @throws 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.
* @throws NullPointerException if the specified object is null
< prev index next >