java.lang.Throwable Class Reference

List of all members.


Detailed Description

This class must be implemented by the VM vendor, or the reference implementation can be used if the documented natives are implemented.

This class is the superclass of all classes which can be thrown by the virtual machine. The two direct subclasses represent recoverable exceptions (Exception) and unrecoverable errors (Error). This class provides common methods for accessing a string message which provides extra information about the circumstances in which the throwable was created, and for filling in a walkback (i.e. a record of the call stack at a particular point in time) which can be printed later.

See also:
Error

Exception

RuntimeException


Public Member Functions

 Throwable ()
 Constructs a new instance of this class with its walkback filled in.
 Throwable (String detailMessage)
 Constructs a new instance of this class with its walkback and message filled in.
 Throwable (String detailMessage, Throwable throwable)
 Constructs a new instance of this class with its walkback, message and cause filled in.
 Throwable (Throwable throwable)
 Constructs a new instance of this class with its walkback and cause filled in.
native Throwable fillInStackTrace ()
 This native must be implemented to use the reference implementation of this class.
String getMessage ()
 Answers the extra information message which was provided when the throwable was created.
String getLocalizedMessage ()
 Answers the extra information message which was provided when the throwable was created.
StackTraceElement[] getStackTrace ()
 Answers an array of StackTraceElement.
void setStackTrace (StackTraceElement[] trace)
 Sets the array of StackTraceElements.
void printStackTrace ()
 Outputs a printable representation of the receiver's walkback on the System.err stream.
void printStackTrace (PrintStream err)
 Outputs a printable representation of the receiver's walkback on the stream specified by the argument.
void printStackTrace (PrintWriter err)
 Outputs a printable representation of the receiver's walkback on the writer specified by the argument.
String toString ()
 Answers a string containing a concise, human-readable description of the receiver.
synchronized Throwable initCause (Throwable throwable)
 Initialize the cause of the receiver.
Throwable getCause ()
 Answers the cause of this Throwable, or null if there is no cause.

Private Member Functions

native StackTraceElement[] getStackTraceImpl ()
 This native must be implemented to use the reference implementation of this class.
StackTraceElement[] getInternalStackTrace ()
 Answers an array of StackTraceElement.
void writeObject (ObjectOutputStream s) throws IOException

Static Private Member Functions

static int countDuplicates (StackTraceElement[] currentStack, StackTraceElement[] parentStack)
 Count the number of duplicate stack frames, starting from the end of the stack.

Private Attributes

String detailMessage
 The message provided when the exception was created.
Throwable cause = this
 The cause of this Throwable.
StackTraceElement[] stackTrace

Static Private Attributes

static final long serialVersionUID = -3042686055658047285L

Constructor & Destructor Documentation

java.lang.Throwable.Throwable (  ) 

Constructs a new instance of this class with its walkback filled in.

java.lang.Throwable.Throwable ( String  detailMessage  ) 

Constructs a new instance of this class with its walkback and message filled in.

Parameters:
detailMessage String The detail message for the exception.

java.lang.Throwable.Throwable ( String  detailMessage,
Throwable  throwable 
)

Constructs a new instance of this class with its walkback, message and cause filled in.

Parameters:
detailMessage String The detail message for the exception.
throwable The cause of this Throwable

java.lang.Throwable.Throwable ( Throwable  throwable  ) 

Constructs a new instance of this class with its walkback and cause filled in.

Parameters:
throwable The cause of this Throwable


Member Function Documentation

native Throwable java.lang.Throwable.fillInStackTrace (  ) 

This native must be implemented to use the reference implementation of this class.

Record in the receiver a walkback from the point where this message was sent. The message is public so that code which catches a throwable and then re-throws it can adjust the walkback to represent the location where the exception was re-thrown.

Returns:
the receiver

String java.lang.Throwable.getMessage (  ) 

Answers the extra information message which was provided when the throwable was created.

If no message was provided at creation time, then answer null.

Returns:
String The receiver's message.

String java.lang.Throwable.getLocalizedMessage (  ) 

Answers the extra information message which was provided when the throwable was created.

If no message was provided at creation time, then answer null. Subclasses may override this method to answer localized text for the message.

Returns:
String The receiver's message.

native StackTraceElement [] java.lang.Throwable.getStackTraceImpl (  )  [private]

This native must be implemented to use the reference implementation of this class.

The result of this native is cloned, and returned from the public API getStackTrace().

Answers an array of StackTraceElement. Each StackTraceElement represents a entry on the stack.

Returns:
an array of StackTraceElement representing the stack

StackTraceElement [] java.lang.Throwable.getStackTrace (  ) 

Answers an array of StackTraceElement.

Each StackTraceElement represents a entry on the stack.

Returns:
an array of StackTraceElement representing the stack

void java.lang.Throwable.setStackTrace ( StackTraceElement[]  trace  ) 

Sets the array of StackTraceElements.

Each StackTraceElement represents a entry on the stack. A copy of this array will be returned by getStackTrace() and printed by printStackTrace().

Parameters:
trace The array of StackTraceElement

void java.lang.Throwable.printStackTrace (  ) 

Outputs a printable representation of the receiver's walkback on the System.err stream.

static int java.lang.Throwable.countDuplicates ( StackTraceElement[]  currentStack,
StackTraceElement[]  parentStack 
) [static, private]

Count the number of duplicate stack frames, starting from the end of the stack.

Parameters:
currentStack a stack to compare
parentStack a stack to compare
Returns:
the number of duplicate stack frames.

StackTraceElement [] java.lang.Throwable.getInternalStackTrace (  )  [private]

Answers an array of StackTraceElement.

Each StackTraceElement represents a entry on the stack. Cache the stack trace in the stackTrace field, returning the cached field when it has already been initialized.

Returns:
an array of StackTraceElement representing the stack

void java.lang.Throwable.printStackTrace ( PrintStream  err  ) 

Outputs a printable representation of the receiver's walkback on the stream specified by the argument.

Parameters:
err PrintStream The stream to write the walkback on.

void java.lang.Throwable.printStackTrace ( PrintWriter  err  ) 

Outputs a printable representation of the receiver's walkback on the writer specified by the argument.

Parameters:
err PrintWriter The writer to write the walkback on.

String java.lang.Throwable.toString (  ) 

Answers a string containing a concise, human-readable description of the receiver.

Returns:
String a printable representation for the receiver.

synchronized Throwable java.lang.Throwable.initCause ( Throwable  throwable  ) 

Initialize the cause of the receiver.

The cause cannot be reassigned.

Parameters:
throwable The cause of this Throwable
Exceptions:
IllegalArgumentException when the cause is the receiver
IllegalStateException when the cause has already been initialized
Returns:
the receiver.

Throwable java.lang.Throwable.getCause (  ) 

Answers the cause of this Throwable, or null if there is no cause.

Returns:
Throwable The receiver's cause.


Member Data Documentation

String java.lang.Throwable.detailMessage [private]

The message provided when the exception was created.

Throwable java.lang.Throwable.cause = this [private]

The cause of this Throwable.

Null when there is no cause.


The documentation for this class was generated from the following file:

Genereated on Tue Dec 9 14:09:48 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.