JDK-6604085 : REGRESSION: InvocationTargetException doesn't print chained exception's stack trace
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: generic
  • CPU: generic
  • Submitted: 2007-09-13
  • Updated: 2010-04-02
  • Resolved: 2007-09-13
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 7
7Resolved
Related Reports
Relates :  
Relates :  
Relates :  
Description
Back in the 1.4 release several exceptions were retrofitted to use the then-new exception chaining facility. See 4209652. These included java.lang.reflect.InvocationTargetException, which represents another exception.

The exception chaining facility provides a general-purpose mechanism for printing stack traces indicating the "cause" of a given exception. Previously, InvocationTargetException had had special-case code for this: see 4086279.

It seems that changing certain exceptions broke serialization; see 4385429. During the fix for this bug, InvocationTargetException was changed to not pass along the given exception to its superclass as its cause, but instead to force a null cause. It overrides java.lang.Throwable.getCause() to provide this wrapped exception in addition to its custom getTargetException(), but printStackTrace() is not overridden.

This means that InvocationTargetException does not use the general-purpose exception chaining mechanism for printing the wrapped exception's stack trace, and also does not provide similar custom code that it had previously to do so. This is a very significant regression that it is surprising has not been reported before. It makes debugging code which prints the stack trace of an InvocationTargetException as its debugging output (such as the AWT Event Dispatch Thread) next to impossible. Ideally a fix for this problem would be backported at least to the 6 update release train, if not earlier.

Comments
EVALUATION Sorry. I misread the output of the application. This is working correctly.
13-09-2007