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

Vicente Romero vromero at openjdk.org
Sun Nov 16 21:05:35 UTC 2025


On Fri, 7 Nov 2025 19:07:15 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

This pull request has now been integrated.

Changeset: b1d14c65
Author:    Vicente Romero <vromero at openjdk.org>
URL:       https://git.openjdk.org/valhalla/commit/b1d14c658511cced2a860d9e2741ae89827e25ba
Stats:     40 lines in 4 files changed: 27 ins; 8 del; 5 mod

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

Reviewed-by: liach

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

PR: https://git.openjdk.org/valhalla/pull/1728


More information about the valhalla-dev mailing list