and the benefit is adding additional information to validation/assertion done by other frameworks. There's always a root cause that has no cause (null), so calling initCause on these root cause exceptions should be possible.
Calling initCause on the root cause would work, if AssertionFailedError wasn't calling super(message, null) or initCause in the constructor. Passing null to super locks in the cause as null without the ability to modify it later.
This project still declars Java 6 as minimum. But this could be remedied with if (cause != null) initCause(cause).
It was possible to work around this by setting the cause reflectively, but this is prohibited now on later Java version (16+).
(Forked from https://github.com/ota4j-team/opentest4j/issues/5#issuecomment-940474063)
The fix (https://github.com/ota4j-team/opentest4j/commit/90db8b4ff81b737b82155880ded7ddff2eb62b0e) for #5 has a side effect that it's not possible to attach a cause on top of the AssertionFailedError.
This used to work:
and the benefit is adding additional information to validation/assertion done by other frameworks. There's always a root cause that has no cause (null), so calling
initCause
on these root cause exceptions should be possible.Calling
initCause
on the root cause would work, ifAssertionFailedError
wasn't callingsuper(message, null)
orinitCause
in the constructor. Passingnull
to super locks in the cause asnull
without the ability to modify it later.This project still declars Java 6 as minimum. But this could be remedied with
if (cause != null) initCause(cause)
.It was possible to work around this by setting the
cause
reflectively, but this is prohibited now on later Java version (16+).