JDK-8230501: Class data support for hidden classes

Mandy Chung mandy.chung at oracle.com
Fri Nov 13 21:50:41 UTC 2020



On 11/13/20 12:32 PM, forax at univ-mlv.fr wrote:
>
> No, the list will be unmodifiable not immutable, a List<Date> is a 
> valid argument but is not immutable because you can change the content 
> of the each date whenever you want.
> Java only provides shallow unmodifiability not true immutability.
>

The unmodifiable list can ensure that class data list behaves as if 
declared as private static final fields, one for each element. W.r.t the 
immutability, there is no difference to 
ConstantBootstraps::getStaticFinal on "private static final Date d".

> Also, List.copyOf() doesn't allow null as element.
>

This is good too.  Why does one want a class list with null elements?


> And, it will also makes classData() pretty useless as a BSM of a condy.

I am also considering the single-item case and allowing Constable 
classdata (after I sent the mail).  In which case, classData() can be 
used to return T (the given type) and classDataAt returns an element at 
the given index of the class data if it's a list.

Mandy


More information about the valhalla-dev mailing list