
6 Jan
2010
6 Jan
'10
9:59 p.m.
It's a great shame that we can't enable assertions by default.
Just looked at the java docs and found the following: Programmers of certain critical systems might wish to ensure that assertions are not disabled in the field. The following static initialization idiom prevents a class from being initialized if its assertions have been disabled: static { boolean assertsEnabled = false; assert assertsEnabled = true; // *Intentional side effect!!!* if (!assertsEnabled) throw new RuntimeException("Asserts must be enabled!!!"); }