Have a look at Contracts for Java, which helps enforing pre- and postconditions as well as invariants through annotations. But there's no compile-time-checking, only runtime as far as I know.
Java - Method Preconditions and postcondition enforcement [closed]
-
10-10-2022 - |
Question
My question is short. Are method preconditions and postconditions enforced by the compiler?
Solution 2
OTHER TIPS
No. Java doesn't have explicit support for design-by-contract pre/postconditions like (for instance) Ada does. See the java docs
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow