-
Bug
-
Resolution: Unresolved
-
P4
-
repo-valhalla
-
generic
-
generic
This ticket is for specification work concerning class literals and Class APIs involving projection types. Once these are specified please assign it back to me for implementation.
As ofJDK-8244796, If V is an inline class that implements I1, I2, ... In,
(a) V.class is typed to be Class<? extends Object & I1 & I2 .. & In> (as an interim measure till full generics story evolves)
(b) V.val class is typed identically to V.class
(c) V.ref.class should be typed to be Class<V.ref> as would be the case for any reference type.
In addition
JDK-8245584 introduced two new APIs viz:
public Optional<Class<T>> valueType();
public Optional<Class<T>> referenceType();
When a method invocation expression involving one of these methods is involved, javac would have to suitably compute the return type of the method expression - a la j.l.O.getClass() (JLS 4.3.2)
Given an inline class V that implements I
The expressions V.class.referenceType(), V.ref.class.referenceType() and V.val.class.referenceType() would have to have the type
Optional<Class<V$ref>>
The expressions V.class.valueType(), V.ref.class.valueType() and V.val.class.valueType() would have to have the type
<TBD>
However, presently the class literal typing story implemented as ofJDK-8244796 is lossy enough that it would block us from typing the class API calls.
For example:
V.class.referenceType() - we would type V.class to be Class<? extends Object & I> and consequently type V.class.referenceType() to be Optional< Class<? extends INT#1>> where
where INT#1 is an intersection type:
INT#1 extends Object,I
From this type it is not possible to deduce Optional<Class<V$ref>>
As of
(a) V.class is typed to be Class<? extends Object & I1 & I2 .. & In> (as an interim measure till full generics story evolves)
(b) V.val class is typed identically to V.class
(c) V.ref.class should be typed to be Class<V.ref> as would be the case for any reference type.
In addition
public Optional<Class<T>> valueType();
public Optional<Class<T>> referenceType();
When a method invocation expression involving one of these methods is involved, javac would have to suitably compute the return type of the method expression - a la j.l.O.getClass() (JLS 4.3.2)
Given an inline class V that implements I
The expressions V.class.referenceType(), V.ref.class.referenceType() and V.val.class.referenceType() would have to have the type
Optional<Class<V$ref>>
The expressions V.class.valueType(), V.ref.class.valueType() and V.val.class.valueType() would have to have the type
<TBD>
However, presently the class literal typing story implemented as of
For example:
V.class.referenceType() - we would type V.class to be Class<? extends Object & I> and consequently type V.class.referenceType() to be Optional< Class<? extends INT#1>> where
where INT#1 is an intersection type:
INT#1 extends Object,I
From this type it is not possible to deduce Optional<Class<V$ref>>