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

[lworld] Add support for denoting and deriving the reference projection

    Details

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

      Description

      From http://cr.openjdk.java.net/~briangoetz/valhalla/sov/02-object-model.html

      Reference projections
      It is often useful to be able to describe the set of references to objects of a given inline class, plus null. Given an inline type V, we would like a type I whose value set is given by:


      ValSet(I) = {null} ∪ {v ∈ ValSet(V) : ref v}

      We call such an interface I a reference projection of V. We can easily construct a reference projection using a sealed interface that permits only a single inline subtype:

      sealed interface I permits V { }
      inline class V implements I { }
      A reference projection plays the role that a wrapper class plays in the current world. But, we don’t want every inline class to have a hand-written, ad-hoc wrapper; we would like to be able to mechanically derive a reference projection from an inline class, and have a uniform way to refer to it – that way we don’t have to maintain a mental dictionary mapping inline classes to their reference projections. For any type T, we would like for T.ref to denote the reference projection of T.

      If an inline class V implements exactly one interface I that meets the requirements above (it is sealed to permit only V), and which implements all the declared superinterfaces of V, then we say I is the reference projection of V, and V.ref is an alias for I. If V does not implement exactly one such interface, than a synthetic interface is implicitly created, and V.ref is an alias for that interface. We lift superinterfaces and public methods of V onto the synthetic interface.

      Because the reference projection is a superinterface of the inline class, there is already an inline widening conversion from V to V.ref. Additionally, we define an inline narrowing conversion from V.ref to V which applies the unref operator, throwing NullPointerException on null.

      // ------------------------------------------------------------------------

      This ticket is to add support for denoting, deriving and representing the reference projection type. (the synthesized super interface)

        Attachments

          Activity

            People

            • Assignee:
              sadayapalam Srikanth Adayapalam
              Reporter:
              sadayapalam Srikanth Adayapalam
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: