jshell + Bach.java compilation issues

Robert Field robert.field at oracle.com
Fri Feb 1 00:32:59 UTC 2019


Hi Christian,

JShell recovers from references to undeclared variables/classes -- as is 
needed for forward references, such as yours.

It detects these based on (hidden to the user, "cannot find symbol") 
underlying javac error messages.  So, for example (extracted and 
simplified example):

jshell> class C { void foo() { var action = Property.ACTION; }}
|  created class C, however, it cannot be instantiated or its methods 
invoked until variable Property is declared

/open and command-line do not show these messages.

Your two layer deep reference to an undeclared identifier generated a 
different error message from javac, and displayed this error:

    jshell> class C { void foo() { var action = Property.ACTION.get(); }}
    |  Error:
    |  package Property does not exist
    |  class C { void foo() { var action = Property.ACTION.get(); }}
    |                                      ^-------------^

When an error, rather than a recoverable undeclared variable occurs, all 
the error messages are shown.

I've created a bug for this:

     https://bugs.openjdk.java.net/browse/JDK-8218179

If it is any consolation, it took me a while to track down the cause.

-Robert


On 1/31/19 6:41 AM, Christian Stein wrote:
> Hi kulla-dev,
>
> I'm still working on Bach.java (Java Shell Builder tool) and today
> its compilation stopped working when `jshell Bach.java` is invoked.
> Same goes for `/open Bach.java` within a jshell session.
>
> Calling `java Bach.java` (JEP 330) runs successfully for all revisions.
>
> I described the issue in more detail at [1] -- here is the gist:
>   - revision from yesterday [2] works
>   - revision from today [3] chokes.
>
> Here is the diff [4] of the two revisions.
>
> I tried hard to find the underlying issue...
>   - renamed types within Bach.java
>   - reduced total file size by
>     - removing unused enum constants
>     - removing all Javadoc
> ...to no avail.
>
> What barrier am I hitting here?
>
> Cheers,
> Christian
>
> [1]https://github.com/sormuras/bach/issues/43
> [2]
> https://raw.githubusercontent.com/sormuras/bach/5e7165ef06c26423d8906038f2e061eb6cd8f374/src/bach/Bach.java
> [3]
> https://raw.githubusercontent.com/sormuras/bach/13cf5eb5a9045ac0158d6da585105d359591ba7f/src/bach/Bach.java
> [4]
> https://github.com/sormuras/bach/commit/13cf5eb5a9045ac0158d6da585105d359591ba7f


More information about the kulla-dev mailing list