[lworld] RFR: 8371382: [lworld] Javac accepts field initializer that refers to a superclass field [v2]

Chen Liang liach at openjdk.org
Mon Nov 10 14:07:16 UTC 2025


On Fri, 7 Nov 2025 19:18:45 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Javac is accepting this code:
>> 
>> 
>> abstract value class ValueParent {
>>     int b = 5;
>> }
>> 
>> value class ValueClass extends ValueParent {
>>     int a = b;
>> }
>> 
>> This is not allowed as in value classes field initializers will run in the prologue phase where references to super class fields are forbidden
>> 
>> TIA
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
> 
>   additional test

Looks reasonable

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

Marked as reviewed by liach (Committer).

PR Review: https://git.openjdk.org/valhalla/pull/1728#pullrequestreview-3443434008


More information about the valhalla-dev mailing list