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

New restrictions on annotations on record components

    XMLWordPrintable

Details

    • CSR
    • Resolution: Withdrawn
    • P3
    • 16
    • tools
    • source
    • minimal
    • Hide
      Record classes have been a preview feature in Java 14 and Java 15. Annotations on record components have been part of the original design. This change could provoke some corner case programs to be rejected, but we don't expect them to be very numerous. Also clients have been warned about the preview nature of record classes in the previous releases
      Show
      Record classes have been a preview feature in Java 14 and Java 15. Annotations on record components have been part of the original design. This change could provoke some corner case programs to be rejected, but we don't expect them to be very numerous. Also clients have been warned about the preview nature of record classes in the previous releases
    • Language construct
    • SE

    Description

      Summary

      Record Classes were originally proposed by JEP 359 and were targeted to JDK 14 as a preview feature. The feature was previewed a second time by JEP 384, which was targeted to JDK 15. One of the most interesting features in record classes is how annotations applied to record components are propagated to elements generated from the record class declaration. Feedback has been positive but suggests that some additional restrictions on annotation propagation are needed.

      Problem

      The current record classes specification defines how annotations on record components are propagated, but in some circumstances (a combination of a particular targeted annotation and an explicit declaration of a particular associated member) an annotation can be lost by not being propagated anywhere. This will be counter-intuitive to developers.

      Solution

      Add new rules to the Java Language Specification capturing these problematic forms of annotated record class declarations, to ensure a compile-time error occurs when an annotation on a record component in a record class declaration would be lost.

      Specification

      Attached are all the specification documents related to records for context. But this CSR is specifically concerned about section: 8.10.5 Record Declarations and Annotations of document: records-jls.html

      Attachments

        Issue Links

          Activity

            People

              vromero Vicente Arturo Romero Zaldivar
              vromero Vicente Arturo Romero Zaldivar
              Gavin Bierman
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: