Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6604085

REGRESSION: InvocationTargetException doesn't print chained exception's stack trace

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Cannot Reproduce
    • Affects Version/s: 7
    • Fix Version/s: 7
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              kbr Kenneth Russell (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: