On Tue, 13 Jan 2026 20:28:02 GMT, Vicente Romero <[email protected]> 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

This pull request has now been integrated.

Changeset: 7aa4941a
Author:    Vicente Romero <[email protected]>
URL:       
https://git.openjdk.org/valhalla/commit/7aa4941a62f7af036b9ea562b928490f0271d64c
Stats:     47 lines in 6 files changed: 44 ins; 0 del; 3 mod

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

Reviewed-by: liach, mcimadamore

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

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

Reply via email to