RFR: 8230501: Class data support for hidden classes [v4]

Mandy Chung mchung at openjdk.java.net
Fri Nov 20 20:26:13 UTC 2020


On Thu, 19 Nov 2020 10:59:30 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Mandy Chung has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fix the name passed to condy calling classData
>
> src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 2148:
> 
>> 2146:          * (unlike private static fields that are accessible to nestmates).
>> 2147:          * Care should be taken w.r.t. mutability for example when passing
>> 2148:          * an array or other mutable structure through the class data.
> 
> I don't think it's necessarily clear _why_/_how_ care should be taken from this text. I suggest:
> Suggestion:
> 
>          * Care should be taken w.r.t. mutability for example when passing
>          * an array or other mutable structure through the class data. Such
>          * a constant should not be mutated, as downstream consumers of
>          * this constant, such as other constants, are not guaranteed to see
>          * the updated value, depending on the timing of their resolution.

What about:

--- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
@@ -2156,8 +2156,10 @@ public class MethodHandles {
          * (unlike private static fields that are accessible to nestmates).
          * Care should be taken w.r.t. mutability for example when passing
          * an array or other mutable structure through the class data.
-         * If you use a {@code List}, it is a good practice to make it unmodifiable
-         * for example via {@link List#of List::of}.
+         * Changing any value stored at the class data at runtime may lead to
+         * unpredictable behavior.
+         * If the class data is a {@code List}, it is a good practice to make it
+         * unmodifiable for example via {@link List#of List::of}.
          *
          * @param bytes     the class bytes
          * @param classData pre-initialized class data

-------------

PR: https://git.openjdk.java.net/jdk/pull/1171


More information about the core-libs-dev mailing list