public interface StaticThrowable
Throwable
is intended to be
created once and reused. Throwables
that implement this interface
kept their state in a RealtimeThread
local data structure instead of
the object itself. This means that data is only valid until the next
StaticThrowable
is thrown in the context of the current thread.
Instances AsyncBaseEventHandler
always have some instance of
RealtimeThread
when executing. Having a marker interface makes it
easier to provide checking tools to ensure the proper throw sequence for all
Throwables
thrown from application code.
Throwables which implement this interface should define a get()
method that returns the singleton throwable of that class. It should also
initialize the stack backtrace. The message and cause should be cleared.
An application which throws a static exception should use the following paradigm:
throw LateStartException.get().initMessage("....").initCause(...);
The message must be initialized before the cause, because initMessage is
defined on StaticThrowable
but not Throwable
. Setting the
message and the cause are both optional.
Applications which define static throwables should extend one of
StaticError
, StaticCheckedException
, or
StaticRuntimeException
ConfigurationParameters
Modifier and Type | Method and Description |
---|---|
java.lang.Throwable |
fillInStackTrace()
Calls into the virtual machine to capture the current stack trace in SO
local memory.
|
java.lang.Throwable |
getCause()
getCause returns the cause of this exception or
null when no cause
was set. |
java.lang.String |
getLocalizedMessage()
Subclasses may override this message to get an error message that is
localized to the default locale.
|
java.lang.String |
getMessage()
get the message describing the problem from SO local memory.
|
java.lang.StackTraceElement[] |
getStackTrace()
Get the stack trace created by fillInStackTrace for this Throwable as an
array of StackTraceElements.
|
java.lang.Throwable |
initCause(java.lang.Throwable causingThrowable)
Initializes the cause to the given Throwable is SO local memory.
|
java.lang.Throwable |
initMessage(java.lang.String message)
Set the message in SO local storage.
|
void |
printStackTrace()
Print stack trace of this Throwable to System.err.
|
void |
printStackTrace(java.io.PrintStream stream)
Print the stack trace of this Throwable to the given stream.
|
void |
printStackTrace(java.io.PrintWriter s)
Print the stack trace of this Throwable to the given PrintWriter.
|
void |
setStackTrace(java.lang.StackTraceElement[] new_stackTrace)
This method allows overriding the stack trace that was filled during
construction of this object.
|
java.lang.Throwable initMessage(java.lang.String message)
java.lang.Throwable
.message
- is the text to save.java.lang.String getMessage()
null
when no
message was set.java.lang.String getLocalizedMessage()
By default it returns getMessage()
.
getMessage()
.java.lang.Throwable initCause(java.lang.Throwable causingThrowable)
causingThrowable
- the reason why this Throwable gets Thrown.java.lang.IllegalArgumentException
- when the cause is this Throwable
itself.java.lang.Throwable getCause()
null
when no cause
was set. The cause is another exception that was caught before this
exception was created.null
.java.lang.Throwable fillInStackTrace()
Throwable
.void setStackTrace(java.lang.StackTraceElement[] new_stackTrace) throws java.lang.NullPointerException
new_stackTrace
- the stack trace to replace be used.java.lang.NullPointerException
- when new_stackTrace or any element of
new_stackTrace is null
.java.lang.StackTraceElement[] getStackTrace()
The stack trace does not need to contain entries for all methods that are actually on the call stack, the virtual machine may decide to skip some stack trace entries. Even an empty array is a valid result of this function.
Repeated calls of this function without intervening calls to fillInStackTrace will return the same result.
When memory areas of the RTSJ are used (see MemoryArea
), and this
Throwable was allocated in a different memory area than the current
allocation context, the resulting stack trace will be allocated in either
the same memory area this was allocated in or the current memory area,
depending on which is the least deeply nested, thereby creating objects
that are assignment compatible with both areas.
null
.void printStackTrace()
The printed stack trace contains the result of toString() as the first line followed by one line for each stack trace element that contains the name of the method or constructor, optionally followed by the source file name and source file line number when available.
void printStackTrace(java.io.PrintStream stream)
The printed stack trace contains the result of toString() as the first line followed by one line for each stack trace element that contains the name of the method or constructor, optionally followed by the source file name and source file line number when available.
stream
- the stream to print to.void printStackTrace(java.io.PrintWriter s)
The printed stack trace contains the result of toString() as the first line followed by one line for each stack trace element that contains the name of the method or constructor, optionally followed by the source file name and source file line number when available.
s
- the PrintWriter to write to.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2017 aicas GmbH. All Rights Reserved.