Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8251034

[lworld] Typing of Class literals and Class APIs involving projection types.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: New
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: repo-valhalla
    • Fix Version/s: None
    • Component/s: specification
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      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 of JDK-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 of JDK-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>>

        Attachments

          Activity

            People

            Assignee:
            dlsmith Dan Smith
            Reporter:
            sadayapalam Srikanth Adayapalam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: