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

[type-restrictions] Generate RestrictedField attributes from annotations

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: repo-valhalla
    • Component/s: tools
    • Labels:
      None

      Description

      To facilitate prototyping in the 'valhalla/type-restrictions' branch:

      Declare a type annotation ('@Target(TYPE_USE)') named 'java.lang.invoke.RestrictedType' whose 'value' element has type String.

      When javac generates code for a field whose type is annotated by @RestrictedType("QFoo;"), it generates a RestrictedField attribute pointing to a Utf8 constant representing the given String.

      There is no need to validate the string—just generate the attribute, and the JVM will interpret it.

      This capability is orthogonal to '-XXflattenWithTypeRestrictions'. That flag supports experiments with different compilation strategies for primitive value types. The @RestrictedType annotation supports ad hoc attribute generation, for more fine-grained control.

      There is no need to support interop between the two approaches—so, for example, when *reading* a class file, if '-XXflattenWithTypeRestrictions' is set, it's okay to assume that the RestrictedField attribute stores that actual Java-language type of the field.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: