Class ThrowsIfViolation

All Implemented Interfaces:
Serializable

public class ThrowsIfViolation extends AssertionViolation
Thrown whenever a @ThrowsIf exceptional-contract violation is detected by a checked arm-set: the method returned normally although a must-throw condition held, or threw a matching exception although no arm's condition held (the latter checked only for exhaustive arm-sets).

Deliberately not the arm's declared exception: the declared exception is defined behaviour delivered at method entry, whereas this violation reports a broken implementation of the contract — late-throwing the declared exception would masquerade the bug as defined behaviour.

Since:
6.0.0
See Also:
  • Constructor Details

    • ThrowsIfViolation

      public ThrowsIfViolation()
      Creates a throws-if violation without an explicit detail message.
    • ThrowsIfViolation

      public ThrowsIfViolation(Object o)
      Creates a throws-if violation with an object-valued detail.
      Parameters:
      o - the detail object
    • ThrowsIfViolation

      public ThrowsIfViolation(boolean b)
      Creates a throws-if violation with a boolean detail.
      Parameters:
      b - the detail value
    • ThrowsIfViolation

      public ThrowsIfViolation(char c)
      Creates a throws-if violation with a char detail.
      Parameters:
      c - the detail value
    • ThrowsIfViolation

      public ThrowsIfViolation(int i)
      Creates a throws-if violation with an int detail.
      Parameters:
      i - the detail value
    • ThrowsIfViolation

      public ThrowsIfViolation(long l)
      Creates a throws-if violation with a long detail.
      Parameters:
      l - the detail value
    • ThrowsIfViolation

      public ThrowsIfViolation(float f)
      Creates a throws-if violation with a float detail.
      Parameters:
      f - the detail value
    • ThrowsIfViolation

      public ThrowsIfViolation(double d)
      Creates a throws-if violation with a double detail.
      Parameters:
      d - the detail value