RFR: 8282160: JShell circularly-required classes cannot be defined

Vicente Romero vromero at openjdk.java.net
Tue Apr 26 17:14:05 UTC 2022


On Mon, 28 Feb 2022 16:08:29 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> 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.

lgtm

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

PR: https://git.openjdk.java.net/jdk/pull/7635


More information about the kulla-dev mailing list