|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Throwable
public class Throwable
Throwable is the root class of all classes whose instances may be thrown as exceptions. It contains basic exception information such as a detailed error message, a cause and stack trace information.
The main subclasses of this class are Error and Exception.
Constructor Summary | |
---|---|
Throwable()
Default constructor to create a Throwable with no detail message and with no cause set. |
|
Throwable(String message)
Create Throwable with the given detail message and with no cause set. |
|
Throwable(String message,
Throwable cause)
Create Throwable with the given message and cause. |
|
Throwable(Throwable cause)
Create Throwable with the given cause and detail message set to cause.toString() in case cause is not null, or no detail message otherwise. |
Method Summary | |
---|---|
Throwable |
fillInStackTrace()
Calls into the virtual machine to fill the current stack trace of this Throwable. |
Throwable |
getCause()
getCause returns the cause of this exception or null if no cause was set. |
String |
getLocalizedMessage()
Subclasses may override this message to get an error message that is localized to the default locale. |
String |
getMessage()
getMessage returns the message describing the problem. |
StackTraceElement[] |
getStackTrace()
Get the stack trace created by fillInStackTrace for this Throwable as an array of StackTraceElements. |
Throwable |
initCause(Throwable causingThrowable)
Initializes the cause to the given Throwable. |
void |
printStackTrace()
Print stack trace of this Throwable to System.err. |
void |
printStackTrace(PrintStream stream)
Print the stack trace of this Throwable to the given stream. |
void |
printStackTrace(PrintWriter s)
Print the stack trace of this Throwable to the given PrintWriter. |
void |
setStackTrace(StackTraceElement[] new_stackTrace)
This method allows to override the stack trace that was filled during construction of this object. |
String |
toString()
Creates a string describing this Throwable. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Throwable()
public Throwable(String message)
ensure
(getMessage() == message);
message
- describing the problem.public Throwable(Throwable cause)
ensure
( (getCause() == cause) && (cause!=null || getMessage() == null) && (cause==null || getMessage().equals(cause.toString());
cause
- of the problempublic Throwable(String message, Throwable cause)
message
- describing the problem.cause
- cause of the problem.Method Detail |
---|
public Throwable fillInStackTrace()
public String getMessage()
public Throwable getCause()
public String getLocalizedMessage()
By default it returns getMessage()
.
getMessage()
.public Throwable initCause(Throwable causingThrowable)
causingThrowable
- the reason why this Throwable gets Thrown.
IllegalArgumentException
- if the cause is this Throwable
itself.
IllegalStateException
- if the cause of this Throwable has
already been initialized.public String toString()
toString
in class Object
public 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 if available.
For JamaicaVM, this routine also works before System was initialized by using low-level exception printing mechanisms provided by class com.aicas.jamaica.lang.Debug.
public void printStackTrace(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 if available.
For JamaicaVM, if printing to the stream causes another exception, low-level exception printing mechanisms provided by class com.aicas.jamaica.lang.Debug will be used to print the exception to stderr.
stream
- the stream to print to.public void printStackTrace(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 if available.
For JamaicaVM, if printing to the PrintWriter causes another exception, low-level exception printing mechanisms provided by class com.aicas.jamaica.lang.Debug will be used to print the exception to stderr.
s
- the PrintWriter to write to.public 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.
For JamaicaVM, the stack trace may omit methods that are compiled by the static compiler. Particularly, methods are compiled and that do not contain an exception handler themselves usually do not require the creation of a stack frame at runtime. To improve performance, no stack frame is generated in these cases.
If 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.
public void setStackTrace(StackTraceElement[] new_stackTrace)
new_stackTrace
- the stack trace to replace be used.
NullPointerException
- if new_stackTrace or any element of
new_stackTrace is null.
|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |