Open wstomv opened 3 years ago
How to define mutually dependent classes with the IJava kernel? ... Any suggestions for a workaround?
I find this annoying too, There is a workaround though. Define empty classes in one cell first and then add their methods.
How to define mutually dependent classes with the IJava kernel?
When I put them in the same code cell, it doesn't work. And when I put them in different cells, it doesn't always work, and needs multiple executions.
For example, the following code won't execute (compile) when put in a single cell (also not when switching the order of the class definitions):
You get an error message for
class C
:If you put them in separate cells, then executing the first cell (with
class C
) gives an error message:Now, the second cell (with
class D
) can be executed without errors. And after that, also the first cell will execute, and both classes seem to work as expected.You can also first execute
class D
, giving rise to the error messageafter which
class C
executes, and then alsoclass D
executes.Unfortunately, in my case the class definitions are a bit more involved, and this approach does not work.
Any suggestions for a workaround?
In a
jshell
this works, though you get a notification stating:I had hoped that IJava would behave similarly.