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

do not allow C-style array declaration in record components

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 16
    • tools
    • None
    • source
    • minimal
    • Language construct
    • SE

      Summary

      The Records spec for JDK 16 does not allow C-style array declarations in record components. The javac compiler should be sync'ed with the spec.

      Problem

      The javac compiler accepts C-style array declarations in record components while the specification for records forbids it. The compiler is accepting code like:

      record R(int i[]) {}

      which is not acceptable according to the Records specification for JDK 16

      Solution

      Sync the javac compiler with the specification.

      Specification

      Section 8.10.1 of the Record specification for JDK 16 defines the syntax of a record component as:

      RecordComponent:
          { Annotation } UnannType Identifier 
          VariableArityRecordComponent 
      VariableArityRecordComponent:
          { Annotation } UnannType { Annotation } ... Identifier

      which clearly forbids C-style array declarations in record components

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

              Created:
              Updated:
              Resolved: