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

Add methods to Elements for record constructors

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 20
    • 19
    • core-libs

      It would be helpful to have methods on `Elements` to determine if the constructor for a method is either a compact constructor or a canonical constructor. Both terms are defined for records in JLS 8.10.4

      For example,
          boolean Elements isCompactConstructor(ExecutableElement ee);
          boolean Elements isCanonicalConstructor(ExecutableElement ee);

      It is not directly possible in the Language Model world to determine if a constructor is a compact constructor (unless it is maybe defined that the parameters are MANDATED). The test for a canonical constructor is moderately expensive and involves looping over the parameters checking the name and type against the corresponding value for each component. Meanwhile, internally, `javac` knows there to both queries, encoded in `Flags.RECORD` and `Flags.COMPACT_RECORD_CONSTRUCTOR`, both defined for `MethodSymbol`.

            darcy Joe Darcy
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: