Conditional compile
Pass all pertinent data to exceptions
AssertionErrorClassLoader regarding
assertions - they are intended for interpreters such as java,
and are not used in a typical program-enableassertions and -disableassertions
runtime parameters
(or their synonyms -ea and -da) control assertions
to any degree of granularityAssertionError behaves as any other Error, and is not
affected by enabling or disabling of assertions.-source 1.4 as a command
line argument to javac| Runtime command line | Classes with assertions enabled |
|---|---|
| java -ea Main | all classes |
| java -ea:com.Blah Main | one particular class named Blah |
| java -ea:com.data... Main | all classes in the com.data package, and all of its sub packages |
| java -ea -da:com.Blah Main | all but one class named Blah |