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

Vicente Romero vromero at openjdk.org
Fri Jan 23 15:30:46 UTC 2026


> 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

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

Changes:
  - all: https://git.openjdk.org/valhalla/pull/1899/files
  - new: https://git.openjdk.org/valhalla/pull/1899/files/8fd1e82f..b1aeb46b

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=valhalla&pr=1899&range=01
 - incr: https://webrevs.openjdk.org/?repo=valhalla&pr=1899&range=00-01

  Stats: 65915 lines in 3133 files changed: 31360 ins; 13537 del; 21018 mod
  Patch: https://git.openjdk.org/valhalla/pull/1899.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1899/head:pull/1899

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


More information about the valhalla-dev mailing list