JDK-8198801 : JShell: user exception chained cause not retained
  • Type: Bug
  • Component: tools
  • Sub-Component: jshell
  • Affected Version: 9,10,11
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-02-28
  • Updated: 2018-04-10
  • Resolved: 2018-04-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b08Fixed
Related Reports
Relates :  
Relates :  
Description
If I evaluate an expression which results in throwing an exception, and that exception has a cause, the cause is not included in the stack trace:

jshell> $8.resolveConstantRef(MethodHandles.lookup())
|  java.lang.BootstrapMethodError thrown: bootstrap method initialization exception
|        at BootstrapMethodInvoker.invoke (BootstrapMethodInvoker.java:174)
|        at ConstantBootstraps.makeConstant (ConstantBootstraps.java:66)
|        at DynamicConstantRef.resolveConstantRef (DynamicConstantRef.java:308)
|        at (#22:1)

This exception had a chained cause, but it wasn't displayed.  (Its pretty hard to debug the above without the underlying cause.)

-----------

The cause is not propagated at initial interception in the execution engine.  This requires changes in the user code execution, the execution SPI, the representation of exceptions on the stream, the handling of evaluation, the JShell API, and the jshell tool.

-----------

The existing jshell tool display format for exceptions was not designed with chained exceptions in mind.  It is not superior to that used by printStackTrace() and the JVM.  Consistency with these is useful for transitioning.  So, the jshell tool will use the standard format (which handles chained exceptions).