private constructors that prevent instantiation of utility classes that only contain static methods; e.g. java.lang.Math
Example
throw new UnsupportedOperationException()
for unimplemented, never-called methods in non-public classes required only to implement an interface; Example: ChildIterator
throw new RuntimeException()
in catch blocks for exceptions that "can't happen" in a correctly functioning VM; e.g. catch UnsupportedEncodingException for the UTF-8 encoding; Example:
nu.xom.Text.build()
fail()
statements when testing for exceptions to be thrown
platform or VM-specific code; especially code for platform specific bugs or workarounds
Calls to System.exit()
:
I checked with JUnit 4 and noticed that it doesn't call System.exit(), so that's something we need to fix.--Kent Beck on the junit mailing list, October 12, 2005