-
Enhancement
-
Resolution: Fixed
-
P3
-
19
-
b10
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`.
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`.
- csr for
-
JDK-8291594 Add methods to Elements for record constructors
-
- Closed
-
- relates to
-
JDK-8291914 generated constructors are considered compact when they shouldn't
-
- Resolved
-
-
JDK-8320200 Use Elements predicates for record constructors to improve print output
-
- Resolved
-
- links to
-
Commit openjdk/jdk/0657acf5
-
Review(master) openjdk/jdk/9694