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

Throwable.printStackTrace(): Unclear truncation rationale

    XMLWordPrintable

Details

    • generic
    • generic

    Description

      A DESCRIPTION OF THE PROBLEM :
      As can be seen in the documentation of printStackTrace(), stacks can be truncated when they are repetitive:

      HighLevelException: MidLevelException: LowLevelException
               at Junk.a(Junk.java:13)
               at Junk.main(Junk.java:4)
       Caused by: MidLevelException: LowLevelException
               at Junk.c(Junk.java:23)
               at Junk.b(Junk.java:17)
               at Junk.a(Junk.java:11)
               ... 1 more
       Caused by: LowLevelException
               at Junk.e(Junk.java:30)
               at Junk.d(Junk.java:27)
               at Junk.c(Junk.java:21)
               ... 3 more
       
      Note the presence of lines containing the characters "...". These lines indicate that the remainder of the stack trace for this exception matches the indicated number of frames from the bottom of the stack trace of the exception that was caused by this exception (the "enclosing" exception). This shorthand can greatly reduce the length of the output in the common case where a wrapped exception is thrown from same method as the "causative exception" is caught.

      https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#printStackTrace--

      Truncating in such cases is wise, but not explaining makes it very confusing. The web is full of people wondering what was truncated and how to get it:
      https://www.eclipse.org/forums/index.php/t/1102920/

      When truncation of a repeated substack is done, the replacement text should be - if not clear - at least distinguishable. For example, instead of just "x more", specify "x more first frames in common".


      Attachments

        Activity

          People

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: