Constructs a new throwable with the specified detail message,
cause, suppression enabled or
disabled, and writable stack trace enabled or disabled. If
suppression is disabled, getSuppressed
for this object
will return a zero-length array and calls to addSuppressed
that would otherwise append an exception to the
suppressed list will have no effect. If the writable stack
trace is false, this constructor will not call fillInStackTrace()
, a null
will be written to the
stackTrace
field, and subsequent calls to
fillInStackTrace
and setStackTrace(StackTraceElement[])
will not set the stack
trace. If the writable stack trace is false, getStackTrace
will return a zero length array.
Note that the other constructors of Throwable
treat
suppression as being enabled and the stack trace as being
writable. Subclasses of Throwable
should document any
conditions under which suppression is disabled and document
conditions under which the stack trace is not writable.
Disabling of suppression should only occur in exceptional
circumstances where special requirements exist, such as a
virtual machine reusing exception objects under low-memory
situations. Circumstances where a given exception object is
repeatedly caught and rethrown, such as to implement control
flow between two sub-systems, is another situation where
immutable throwable objects would be appropriate.
message | the detail message. | |
cause | the cause. (A null value is permitted,
and indicates that the cause is nonexistent or unknown.) | |
enableSuppression | whether or not suppression is enabled or disabled | |
writableStackTrace | whether or not the stack trace should be writable |
OutOfMemoryError, NullPointerException, ArithmeticException
Diagram: Exceptions