REPL bugs

Robert Field robert.field at oracle.com
Fri Feb 20 19:09:28 UTC 2015


Thanks, will address.

As to final, this is problematic as definition is separated from execution.

-Robert



On February 20, 2015 10:59:47 AM Brian Goetz <brian.goetz at oracle.com> wrote:

> Seems we are ignoring finality for both REPL-level vars and classes.
> But, unlike some other modifiers we ignore, these do have a sensible
> interpretation?
>
> repl> final int x = 3;
>    x
>
> repl> x = 4;
>    no error
>
> -----
>
> repl> final class Foo { }
>    Foo
>
> repl> class Bar extends Foo { }
>    no error
>
> repl> new Bar()
>    no error
>
> -----
>
> repl> return 3
>    // nothing
>
> Probably best to reject "return x" as not being a statement that makes
> sense at top-level.
>
> -----
>
> -> System.exit(0)
> |  State engine terminated.  Resetting...
>
> -> new Thread() { public void run() { System.exit(0); } }.start()
> |  State engine terminated.  Resetting...
>
> Nice!
>
> -----
>
> Both static initializers and instance initializers seem to get executed
> as expressions:
>
> -> static { System.out.println("x"); }
> x
>
> -> { System.out.println("x"); }
> x
>
> But I don't think these make sense at the top level -- they should
> probably be rejected.  (Arguably the latter might be interpreted as
> simply creating a new lexical scope, but the former is definitely a
> static initializer.)




More information about the kulla-dev mailing list