Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2048000 | 1.4.0 | Josh Bloch | P3 | Resolved | Fixed | rc1 |
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.
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.
- backported by
-
JDK-2048000 AssertionError whose "detail message" is Throwable should set cause
-
- Resolved
-
- relates to
-
JDK-6302175 Second argument of assert statement not always converted to a String
-
- Closed
-