State engine terminates when throwing self-caused exception

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • 26
    • Affects Version/s: 25
    • Component/s: tools
    • None
    • In Review

      jshell> new Throwable()
      $1 ==> java.lang.Throwable

      jshell> new Throwable()
      $2 ==> java.lang.Throwable

      jshell> $1.initCause($2)
      $3 ==> java.lang.Throwable

      jshell> $2.initCause($1)
      $4 ==> java.lang.Throwable

      jshell> throw $1
      | State engine terminated.
      | Restore definitions with: /reload -restore

      jshell>

      ---
      It's likely a low-priority corner case. java.lang.ThreadGroup.uncaughtException uses Throwable.printStackTrace(System.err), which has guards against it, but JShell uses something else, that doesn't:

      jshell> /reload -restore
      | Restarting and restoring from previous state.
      -: new Throwable()
      -: new Throwable()
      -: $1.initCause($2)
      -: $2.initCause($1)

      jshell> $1.printStackTrace()
      java.lang.Throwable
      at REPL.$JShell$2.do_it$($JShell$2.java:7)
      at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
      at java.base/java.lang.reflect.Method.invoke(Method.java:565)
      at jdk.jshell/jdk.jshell.execution.DirectExecutionControl.invoke(DirectExecutionControl.java:227)
      at jdk.jshell/jdk.jshell.execution.RemoteExecutionControl.invoke(RemoteExecutionControl.java:121)
      at jdk.jshell/jdk.jshell.execution.DirectExecutionControl.invoke(DirectExecutionControl.java:125)
      at jdk.jshell/jdk.jshell.execution.ExecutionControlForwarder.processCommand(ExecutionControlForwarder.java:148)
      at jdk.jshell/jdk.jshell.execution.ExecutionControlForwarder.commandLoop(ExecutionControlForwarder.java:266)
      at jdk.jshell/jdk.jshell.execution.Util.forwardExecutionControl(Util.java:78)
      at jdk.jshell/jdk.jshell.execution.Util.forwardExecutionControlAndIO(Util.java:148)
      at jdk.jshell/jdk.jshell.execution.RemoteExecutionControl.main(RemoteExecutionControl.java:74)
      Caused by: java.lang.Throwable
      at REPL.$JShell$3.do_it$($JShell$3.java:7)
      ... 10 more
      Caused by: [CIRCULAR REFERENCE: java.lang.Throwable]

      jshell>

            Assignee:
            Christian Stein
            Reporter:
            Pavel Rappo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: