RFR: 8230501: Class data support for hidden classes [v4]
Jorn Vernee
jvernee at openjdk.java.net
Fri Nov 20 20:33:06 UTC 2020
On Fri, 20 Nov 2020 20:23:27 GMT, Mandy Chung <mchung at openjdk.org> wrote:
>> 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
Looks good!
-------------
PR: https://git.openjdk.java.net/jdk/pull/1171
More information about the core-libs-dev
mailing list