Question

My question is short. Are method preconditions and postconditions enforced by the compiler?

Was it helpful?

Solution 2

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.

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
scroll top