[lworld] RFR: JDK-8251986: [lworld] implement Class::valueType and Class::referenceType in Java
Roger Riggs
rriggs at openjdk.java.net
Wed Aug 19 19:31:20 UTC 2020
On Tue, 18 Aug 2020 19:47:36 GMT, Mandy Chung <mchung 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 631:
> 630: } else if (isReferenceProjectionType()) {
> 631: projectionTypes = new Class<?>[] { valueProjectionType(), this };
> 632: } else {
It seems odd that isReferenceProjectType() uses projectionTypes before it is initialized (or is it re-initialized).
(Though there is a check for null).
The logic is not very straightforward; though I haven't looked at how to make it easier to follow.
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).
-------------
PR: https://git.openjdk.java.net/valhalla/pull/152
More information about the valhalla-dev
mailing list