RFR: 8282160: JShell circularly-required classes cannot be defined
Jan Lahoda
jlahoda at openjdk.java.net
Mon Feb 28 16:15:21 UTC 2022
Consider JShell snippets like:
jshell> class B {
C c;
public void run() {
}
}
jshell> class C extends B {
public void run() {
}
}
When the first snippet is processed, it cannot be fully compiled, because `C` is missing. When the second snippet is processed, it is first processed separately, but it will turn out it needs `B` to be defined, and that there are no errors in `C` except resolution errors, and JShell will process both the snippets together, which will pass.
If the second snippet is changed to:
jshell> class C extends B {
@Override
public void run() {
}
}
then when processing `C`, there will be error: "method does not override or implement a method from a supertype" (in addition to the "`B` does not exist"). But that error is not considered a resolution error by JShell.
The proposal here is to ignore the "does not override" errors and join the `C` and `B` snippet processing. An alternative would be to not produce the error when there are erroneous supertypes, but that turns out to be tricky when the error is not in the direct supertype. So the proposal is to tweak JShell for now.
-------------
Commit messages:
- 8282160: JShell circularly-required classes cannot be defined
Changes: https://git.openjdk.java.net/jdk/pull/7635/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7635&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8282160
Stats: 34 lines in 3 files changed: 28 ins; 0 del; 6 mod
Patch: https://git.openjdk.java.net/jdk/pull/7635.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/7635/head:pull/7635
PR: https://git.openjdk.java.net/jdk/pull/7635
More information about the kulla-dev
mailing list