-
Bug
-
Resolution: Fixed
-
P3
-
23
-
b03
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8334954 | 23.0.1 | Vicente Arturo Romero Zaldivar | P3 | Resolved | Fixed | b02 |
JDK-8334661 | 23 | Vicente Arturo Romero Zaldivar | P3 | Closed | Fixed | b29 |
CtorPrologueBugTest {
int x;
CtorPrologueBugTest() {
class Inner {
{ System.out.println(x); }
}
super();
}
}
Prior to
CtorPrologueBugTest.java:5: error: cannot reference x before supertype constructor has been called
{ System.out.println(x); }
^
After
CtorPrologueBugTest.java:5: error: no enclosing instance of type CtorPrologueBugTest is in scope
{ System.out.println(x); }
^
There are two problems with this change in behavior:
1. Such errors should be detected by `Attr.java`, not `Lower.java`, so that IDE's that only display errors generated by earlier compilation phases will show them.
2. The wording change in the error message is technically incorrect: x is in scope, it's just not yet accessible.
This change in behavior reflects an underlying logic bug, which is that Attr::visitClassDef is setting ctorPrologue = false on the containing class' environment, instead of the nested class' environment.
- backported by
-
JDK-8334954 Improve error for illegal early access from nested class
- Resolved
-
JDK-8334661 Improve error for illegal early access from nested class
- Closed
- csr for
-
JDK-8334764 Improve error for illegal early access from nested class
- Closed
- relates to
-
JDK-8334762 [BACKOUT BACKPORT] Improve error for illegal early access from nested class
- Resolved
- links to
-
Commit openjdk/jdk/7b3a96d5
-
Commit openjdk/jdk/e84e0cdf
-
Review openjdk/jdk/19773
-
Review openjdk/jdk/19797