RFR: 8332600: javac uses record components source position during compilation [v2]

Jan Lahoda jlahoda at openjdk.org
Thu Jul 18 14:14:32 UTC 2024


On Fri, 12 Jul 2024 20:24:23 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> javac uses the source position of record components to find and later probably remove a given record component during compilation. This could be necessary if annotation processors are present. This is done in part to provide better error messages for silly record definitions like:
>> 
>> record R(int i, float i) {} // two record components with the same name
>> 
>> but this is brittle and can backfire if the record is read from a class file as the source positions are not stored there. See [JDK-8332297](https://bugs.openjdk.org/browse/JDK-8332297) for some context
>> 
>> The idea of this fix is not to use the source position but only the name to find a given record component. This could imply that if the user defines an erroneous record like the one above, then the record could end up with less record components than expected but records like this wouldn't compile anyway
>> 
>> TIA
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
> 
>   review comments

Seems OK to me.

-------------

Marked as reviewed by jlahoda (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20148#pullrequestreview-2185954109


More information about the compiler-dev mailing list