[lworld] RFR: JDK-8251986: [lworld] implement Class::valueType and Class::referenceType in Java

Mandy Chung mchung at openjdk.java.net
Wed Aug 19 20:44:46 UTC 2020


On Wed, 19 Aug 2020 19:26:25 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Now that javac generates the reference projection class as a sealed type,
>> this patch reimplements  `Class::valueType` and `Class::referenceType` in Java.
>> VM no longer has any knowledge of the value projection type and reference projection type.
>> 
>> This patch includes a temporary workaround to disable the preview feature check
>> for sealed types because inline types are not (yet) a preview feature in valhalla repo.
>> This workaround should be removed when it's time to make inline class a preview feature.
>
> src/java.base/share/classes/java/lang/Class.java line 666:
> 
>> 665:                 try {
>> 666:                     Class<?> valType = Class.forName(cn, false, getClassLoader());
>> 667:                     if (valType.isInlineClass()) {
> 
> The lookup by name implies that hidden classes can not be value classes (because they cannot be resolved by name).

An inline hidden class cannot be named and hence it can't be listed in `PermittedSubclasses`.  In other words, it can't
do like the language translation to translate an inline class `V` to have a pair `V$ref` and `V$val extends V$ref`.

A hidden class can be an inline class without the reference projection type.

> src/java.base/share/classes/java/lang/Class.java line 605:
> 
>> 604:         ensureProjectionTypesInited();
>> 605:         System.out.println(getName() + " " + Arrays.toString(projectionTypes));
>> 606:         return projectionTypes.length == 2 ? Optional.of(projectionTypes[1]) : Optional.empty();
> 
> Remove the println.

Thanks for catching that.

> src/java.base/share/classes/java/lang/Class.java line 584:
> 
>> 583:         ensureProjectionTypesInited();
>> 584:         System.out.println(getName() + " " + Arrays.toString(projectionTypes));
>> 585:         return projectionTypes.length > 0 ? Optional.of(projectionTypes[0]) : Optional.empty();
> 
> println?

Leftover debugging code.  Will remove

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

PR: https://git.openjdk.java.net/valhalla/pull/152


More information about the valhalla-dev mailing list