Local execution mode and local variables

Christian Stein sormuras at gmail.com
Thu Feb 22 14:54:30 UTC 2018


Hi,

The following script leads to unexpected loss
of an object reference when jshell is launched
with option "--execution local":

  class A { int a() { int error = 0; return error; } }
  A a = new A()
  System.out.println("before error | a = " + a)
  int error = 4711
  System.out.println("after error  | a = " + a)
  System.out.println("           error = " + error)
  /exit

Normal mode:

jshell execution-local-fails.jsh

before error | a = REPL.$JShell$11$A at 7d9d1a19
after error  | a = REPL.$JShell$11$A at 7d9d1a19
           error = 4711


Local mode:

jshell --execution local execution-local-fails.jsh

before error | a = REPL.$JShell$11$A at 25df00a0
after error  | a = null
           error = 4711



Is this behaviour expected?

Tested on 9.0.1, 9.0.4 and current 10+44.

Work around in "local mode": use a different
name for the local variable.

Cheers,
Christian


More information about the kulla-dev mailing list