[lworld] RFR: 8371356: [lworld] 'super' should be rejected in early construction context

Vicente Romero vromero at openjdk.org
Mon Nov 17 19:16:32 UTC 2025


On Mon, 17 Nov 2025 18:29:43 GMT, Chen Liang <liach at openjdk.org> wrote:

>> There is a bug in the algo to determine what is kosher and what is not in early construction contexts. The algo was not analyzing any static symbol. But according to the `JLS 25 15.11.2 Accessing Superclass Members using super`:
>> 
>> 
>> It is a compile-time error if a field access expression using the keyword super
>> occurs in a static context (§8.1.3) or in an early construction context (§8.8.7) of
>> the current class.
>> 
>> the previous code was checking this only for instance field accesses. The current fix corrects this bug
>> 
>> TIA
>
> test/langtools/tools/javac/SuperInit/SuperInitFails.java line 282:
> 
>> 280:         class Inner9Test extends Medium {
>> 281:             Inner9Test() {
>> 282:                 boolean check1 = Inner9Test.super.check;
> 
> Should the test also use `Parent.super.check` and `Medium.super.check`?

in those cases javac already fails with:

`error: not an enclosing class: ClassName`

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1740#discussion_r2535238928


More information about the valhalla-dev mailing list