public final class ThrowsIfSupport
extends Object
Runtime support for checked @ThrowsIf arm-sets (invoked from
generated code; not intended to be called by user code). The checks report a
broken contract implementation as a ThrowsIfViolation — never
as the arm's declared exception, which is defined behaviour delivered at method
entry.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static void |
mustThrow(boolean[] held, String[] conditions)The must-throw check, run when the method body completes normally: no unwoven arm's condition may have held on entry (a woven arm's guard makes this unreachable for that arm by construction). |
|
public static Throwable |
onlyWhen(Throwable thrown, boolean[] held, Class<?>[] types, String[] conditions, boolean exhaustive)The only-when check, run when the method body throws: a throwable matching some arm's exception type must be justified by some matching arm's condition having held on entry. |
The must-throw check, run when the method body completes normally: no unwoven arm's condition may have held on entry (a woven arm's guard makes this unreachable for that arm by construction).
held - per-unwoven-arm: whether the arm's condition held on entryconditions - per-unwoven-arm: the arm's condition text (for the violation message) The only-when check, run when the method body throws: a throwable
matching some arm's exception type must be justified by some matching arm's
condition having held on entry. A justified (or unmatched, or
non-exhaustive) throwable is returned for rethrow — defined
behaviour propagates untouched.
VirtualMachineErrors (OutOfMemoryError, StackOverflowError,
...) are never judged, whatever the arm types: a VM resource condition is outside
contract semantics — no @ThrowsIf claim, however exhaustive, reasons
about it — so it always propagates untouched.
thrown matches an arm's type but no
matching arm's condition heldthrown - the throwable escaping the method bodyheld - per-arm: whether the arm's condition held on entrytypes - per-arm: the arm's declared exception typeconditions - per-arm: the arm's condition text (for the violation message)exhaustive - whether the whole arm-set claims exhaustiveness (an iff);
one-directional arm-sets are never only-when checkedthrown, for rethrow, when it is in-contract