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

Vicente Romero vicente.romero at oracle.com
Tue Jan 14 23:25:09 UTC 2020


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