[jdk19] RFR: JDK-8275784: Bogus warning generated for record with compact constructor [v2]

Jonathan Gibbons jjg at openjdk.org
Mon Jun 27 17:22:47 UTC 2022

On Mon, 27 Jun 2022 17:11:23 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> I don't see how we can avoid duplication at this time.
> It's not actually clear that `java.lang.model` has the info to provide this method, since the compact constructor is a syntactic form, that has disappeared by the time we get to the `ExecutableElement` for the constructor.  Sure, we could provide the method, but it's not clear we can detect the difference between the compact form and the use of explicit parameters.  I guess we could maybe put it on `Trees` if there is enough info on the AST, if it hasn't already been desugared away.
> At some level, it comes down to ... do we allow the `@param` tags to be only omitted on the compact constructor (no args provided), or on the canonical constructor where the param names match the component names.

Reading JLS [8.10.4](https://docs.oracle.com/javase/specs/jls/se18/html/jls-8.html#jls-8.10.4) we could suggest `isCanonicalConstructor` for `java.lang.model`, use that, and ignore whether it is a compact t constructor or an explicitly declared canonical constructor.


PR: https://git.openjdk.org/jdk19/pull/70

More information about the compiler-dev mailing list