[lworld] RFR: 8373916: [lworld] TypeName.this.FieldName should be restricted in early construction context [v2]

Chen Liang liach at openjdk.org
Fri Jan 30 03:46:29 UTC 2026


On Fri, 23 Jan 2026 15:30:46 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> According to spec bugs: JDK-8373719 and JDK-8373721:
>> 
>> In JLS 6.5.6.1, references to fields are subject to a handful of restrictions if they refer to instance fields. In 15.8 and 15.11, 'this.x' and 'super.x' are intended to be viewed as instance field references, and subject to the same restrictions.
>> 
>> So the following code should fail to compile:
>> 
>> class Test {
>>     static final boolean check = true;
>>     Test(int a) {
>>         boolean b = Test.this.check; //compilation error expected here
>>         this();
>>     }
>> }
>> 
>> However, javac is currently accepting it
>
> Vicente Romero has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
> 
>  - adding test case
>  - Merge branch 'lworld' into JDK-8373916
>  - 8373916: [lworld] TypeName.this.FieldName should be restricted in early construction context

lgtm

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

Marked as reviewed by liach (Committer).

PR Review: https://git.openjdk.org/valhalla/pull/1899#pullrequestreview-3726178434


More information about the valhalla-dev mailing list