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

Vicente Romero vicente.romero at oracle.com
Wed Jan 15 00:48:35 UTC 2020


Hi,

Thanks for the review.

On 1/14/20 6:34 PM, Maurizio Cimadamore wrote:
> Looks good - should (maybe in the future) the implementation class for 
> record component symbol point to the synthetic field derived from it?

yep we could do that

>
> Maurizio

Vicente

>
> 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