-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
P4
-
Affects Version/s: repo-valhalla
-
Component/s: tools
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.
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.
- relates to
-
JDK-8373719 Clarify rules for this/super field accesses in early construction
-
- Open
-
-
JDK-8373721 [lworld] value-objects-jls: fix JLS rules for this-qualified field accesses
-
- Open
-