Top Description Fields Constructors Methods
org.apache.derby.shared.common.sanity

public Class AssertFailure

extends RuntimeException
Class Inheritance
Imports
java.io.PrintStream, .PrintWriter, .StringWriter, java.lang.reflect.InvocationTargetException, .Method

AssertFailure is raised when an ASSERT check fails. Because assertions are not used in production code, are never expected to fail, and recovering from their failure is expected to be hard, they are under RuntimeException so that no one needs to list them in their throws clauses. An AssertFailure at the outermost system level will result in system shutdown. An AssertFailure also contains a string representation of a full thread dump for all the live threads at the moment it was thrown if the JVM supports it and we have the right permissions. If the JVM doesn't have the method Thread.getAllStackTraces i.e, we are on a JVM < 1.5, or if we don't have the permissions java.lang.RuntimePermission "getStackTrace" and "modifyThreadGroup", a message saying so is stored instead. The thread dump string is printed to System.err after the normal stack trace when the error is thrown, and it is also directly available by getThreadDump().

Field Summary

Modifier and TypeField and Description
private String

Constructor Summary

AccessConstructor and Description
public
AssertFailure(String
the message associated with the error.
message
,
Throwable
errors can be nested together; if this error has another error associated with it, it is specified here. The 'outermost' error should be the most severe error; inner errors should be providing additional information about what went wrong.
nestedError
)

This constructor takes the pieces of information expected for each error.

public
AssertFailure(String
the message associated with the error.
message
)

This constructor takes the just the message for this error.

public
AssertFailure()

This constructor expects no arguments or nested error.

Method Summary

Modifier and TypeMethod and Description
private String

Returns:

stack traces for all live threads as a string or an error message.
dumpThreads
()

Dumps stack traces for all the threads if the JVM supports it.

public String

Returns:

- thread dump string.
getThreadDump
()

Returns the thread dump stored in this AssertFailure as a string.

public void
printStackTrace()

Overrides java.lang.Throwable.printStackTrace.

Overrides printStackTrace() in java.lang.Throwable to include the thread dump after the normal stack trace.
public void
printStackTrace(PrintStream
PrintStream to use for output
s
)

Overrides java.lang.Throwable.printStackTrace.

Overrides printStackTrace(PrintStream s) in java.lang.Throwable to include the thread dump after the normal stack trace.
public void
printStackTrace(PrintWriter
PrintWriter to use for output
s
)

Overrides java.lang.Throwable.printStackTrace.

Overrides printStackTrace(PrintWriter s) in java.lang.Throwable to include the thread dump after the normal stack trace.
private boolean
supportsThreadDump()

Tells if generating a thread dump is supported in the running JVM.

Field Detail

threadDumpback to summary
private String threadDump

Constructor Detail

AssertFailureback to summary
public AssertFailure(String message, Throwable nestedError)

This constructor takes the pieces of information expected for each error.

Parameters
message:String

the message associated with the error.

nestedError:Throwable

errors can be nested together; if this error has another error associated with it, it is specified here. The 'outermost' error should be the most severe error; inner errors should be providing additional information about what went wrong.

AssertFailureback to summary
public AssertFailure(String message)

This constructor takes the just the message for this error.

Parameters
message:String

the message associated with the error.

AssertFailureback to summary
public AssertFailure()

This constructor expects no arguments or nested error.

Method Detail

dumpThreadsback to summary
private String dumpThreads()

Dumps stack traces for all the threads if the JVM supports it. The result is returned as a string, ready to print. If the JVM doesn't have the method Thread.getAllStackTraces i.e, we are on a JVM < 1.5, or if we don't have the permissions: java.lang.RuntimePermission "getStackTrace" and "modifyThreadGroup", a message saying so is returned instead.

Returns:String

stack traces for all live threads as a string or an error message.

getThreadDumpback to summary
public String getThreadDump()

Returns the thread dump stored in this AssertFailure as a string.

Returns:String

- thread dump string.

printStackTraceback to summary
public void printStackTrace()

Overrides java.lang.Throwable.printStackTrace.

Overrides printStackTrace() in java.lang.Throwable to include the thread dump after the normal stack trace.

printStackTraceback to summary
public void printStackTrace(PrintStream s)

Overrides java.lang.Throwable.printStackTrace.

Overrides printStackTrace(PrintStream s) in java.lang.Throwable to include the thread dump after the normal stack trace.

Parameters
s:PrintStream

Doc from java.lang.Throwable.printStackTrace.

PrintStream to use for output

printStackTraceback to summary
public void printStackTrace(PrintWriter s)

Overrides java.lang.Throwable.printStackTrace.

Overrides printStackTrace(PrintWriter s) in java.lang.Throwable to include the thread dump after the normal stack trace.

Parameters
s:PrintWriter

Doc from java.lang.Throwable.printStackTrace.

PrintWriter to use for output

supportsThreadDumpback to summary
private boolean supportsThreadDump()

Tells if generating a thread dump is supported in the running JVM.