TypeName.this.FieldName should be restricted in early construction context

XMLWordPrintable

      According to JDK-8373719 and JDK-8373721,

      In 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:
      jshell> class Test {
         ...> static final boolean check = true;
         ...>
         ...> Test(int a) {
         ...> boolean b = Test.this.check; //compilation error expected here
         ...> this();
         ...> }
         ...> }

      However, with valhalla EA2, it compiles.

            Assignee:
            Vicente Arturo Romero Zaldivar
            Reporter:
            Ella Ananeva
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: