Java Reference
In-Depth Information
assert assertsEnabled = true;
if (!assertsEnabled)
throw new IllegalStateException("Asserts required");
}
In this code we purposefully use a side effect of the assert statement so
that the code can determine whether asserts have been turned offif they
have then the class will not load. This is a nearly unique case in which
side effects are a good thing.
Requiring assertions to be on complicates the running environment of
the code since it must always turn on assertions for this class even if
they are off elsewhere. You should do this almost, if not actually, never.
The greatest of all faults is to be conscious of none.
Thomas Carlyle
 
Search WWH ::




Custom Search