RFR JDK-15: 8236682: Javac generates a redundant FieldRef constant for record fields

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Jan 14 23:34:50 UTC 2020


Looks good - should (maybe in the future) the implementation class for 
record component symbol point to the synthetic field derived from it?

Maurizio

On 14/01/2020 23:25, Vicente Romero wrote:
> Please review the fix for [1] at [2]. Javac is generating a redundant 
> FieldRef for each instance field in a record. The bug was that when 
> generating the body for the accessor, basically the return statement 
> as in:
>
> record R(int i) {}, javac generates accessor:
>
> public int i() {
>     return i;  <-------------  this statement
> }
>
> so for the return statement javac was using the record component's 
> symbol instead of using the field's symbol. As a result there were two 
> FieldRef entries in the constant pool per field. This patch fixes this 
> issue,
>
> Thanks,
> Vicente
>
> [1] https://bugs.openjdk.java.net/browse/JDK-8236682
> [2] http://cr.openjdk.java.net/~vromero/8236682/webrev.00/
>


More information about the compiler-dev mailing list