RFR: 8292159: TYPE_USE annotations on generic type arguments of record components discarded [v3]
Srikanth Adayapalam
sadayapalam at openjdk.org
Thu Oct 20 08:28:51 UTC 2022
On Thu, 20 Oct 2022 05:28:10 GMT, Srikanth Adayapalam <sadayapalam at openjdk.org> wrote:
>> Handle carryover of type annotations to record components in a place which will be
>> reached regardless of whether there are any annotations in a SE5 annotation location.
>
> Srikanth Adayapalam has updated the pull request incrementally with one additional commit since the last revision:
>
> Incorporate review comments from Vicente (Thanks!)
For the record(sic!) , javac's implementation seems to use terminology that differs from JLS (but still may be producing fully equivalent implementation)
See that JLS 8.10.1 says:
The record components of a record class, if any, are specified in the header of a
record declaration. Each record component consists of a type (optionally preceded
by one or more annotations) and an identifier that specifies the name of the
record component. A record component corresponds to two members of the record
class: a private field declared implicitly, and a public accessor method declared
explicitly or implicitly (§8.10.3).
Javac implementation treats the declaration in the record header as a component field
and generates record component from that.
In doing so, it is aligning with terminology used by JDK, which treats the components of
the record attribute as Record components.
The following is from Class.java
/*
* Returns an array containing the components of the Record attribute,
* or null if the attribute is not present.
*
* Note that this method returns non-null array on a class with
* the Record attribute even if this class is not a record.
*/
private native RecordComponent[] getRecordComponents0();
This may be just splitting hairs - but at least initially it is a bit confusing that we go from components fields to record components in javac implementation rather than vice versa.
As called out before, the net effect may be that a totally equivalent implementation results.
-------------
PR: https://git.openjdk.org/jdk/pull/10741
More information about the compiler-dev
mailing list