AssertionError whose "detail message" is Throwable should set cause

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P3
    • 1.4.1
    • Affects Version/s: 1.4.0
    • Component/s: core-libs
    • None
    • hopper
    • generic
    • generic
    • Verified

        One common use of assertions is to assert "this line can't be reached" it's not
        uncommon to have constructs such as:

          try {
            doSomething();
          } catch (SomeException se) {
            // can't really get here because doSomething() can't really throw
            // SomeException in this context, despite it's signature.
          }

        To achieve failure capture in an assertion, one would do this:

          try {
            doSomething();
          } catch (SomeException se) {
            assert false : se;
          }

        If the AssertionError has SomeException as its cause, the resulting stack
        trace will be FAR more informative. Note that this is just an API refinement:
        it is consistent with the existing spec.

              Assignee:
              Josh Bloch (Inactive)
              Reporter:
              Josh Bloch (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: