Issues regarding imports
Brian Goetz
brian.goetz at oracle.com
Mon Jun 29 18:48:40 UTC 2015
There definitely needs to be a way to /drop an ill-considered import
directive; otherwise your session is tainted.
The continued re-processing of a bogus import is probably a bug.
I don't like the idea of a deliberately modal interaction like this (it
would play havoc, for example, when you pipe in input), but I like the
idea of the hints. Maybe it could create some temporary context:
repl> Predicate<Integer> p;
| Class Predicate not found, but I have some suggestions:
Type /accept 1 for java.util.function.Predicate
Type /accept 2 for javax.sql.rowset.Predicate
repl>
and then the user could either accept the advice, or move on, but not
get stuck in a modal interaction that they don't know how to get out of.
On 6/29/2015 6:23 AM, Roy van Rijn wrote:
> Hey all,
>
> After exploring the JShell a little more I've found one annoyance and
> one possible improvement.
>
> If you have an illegal import you'll get an error message. There is
> already an issue in the JBS about the formatting of this error
> (JDK-8129418), but the thing that bugs me is the following:
>
> ==================
> -> import unknown.*
> | Error:
> | package unknown does not exist
> | import unknown.*;
> | ^
>
> -> System.out.println("Test");
> | Error:
> | package unknown does not exist
> | import unknown.*;
> | ^
> Test
> ==================
>
> It keeps repeating the unknown import for each consecutive call. This
> looks like a bug to me.
>
> One thing I was wondering about, now that we have code completion,
> would it be possible to have automatic imports as well? If I mention a
> class that is currently unknown, maybe it could prompt possible
> imports? Most of the time there are just a few implementations anyway.
> Here is how it *could* work in the JShell:
>
> ==================
> -> Predicate<Integer> isEven = n -> n%2==0;
> Class Predicate not found, did you mean:
> 1) java.util.function.Predicate
> 2) javax.sql.rowset.Predicate
> 3) javax.persistence.criteria.Predicate
>
> 1
>
> Class java.util.function.Predicate added as import.
> ->
> ==================
>
> Just a suggestion, any thoughts?
>
> Roy
>
More information about the kulla-dev
mailing list