org.apache.derby.shared.common.sanity
Class AssertFailure

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by org.apache.derby.shared.common.sanity.AssertFailure
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AssertFailure

public class AssertFailure
extends java.lang.RuntimeException

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().

See Also:
Serialized Form

Field Summary
private  java.lang.String threadDump
           
 
Constructor Summary
AssertFailure()
          This constructor expects no arguments or nested error.
AssertFailure(java.lang.String message)
          This constructor takes the just the message for this error.
AssertFailure(java.lang.String message, java.lang.Throwable nestedError)
          This constructor takes the pieces of information expected for each error.
 
Method Summary
private  java.lang.String dumpThreads()
          Dumps stack traces for all the threads if the JVM supports it.
 java.lang.String getThreadDump()
          Returns the thread dump stored in this AssertFailure as a string.
 void printStackTrace()
          Overrides printStackTrace() in java.lang.Throwable to include the thread dump after the normal stack trace.
 void printStackTrace(java.io.PrintStream s)
          Overrides printStackTrace(PrintStream s) in java.lang.Throwable to include the thread dump after the normal stack trace.
 void printStackTrace(java.io.PrintWriter s)
          Overrides printStackTrace(PrintWriter s) in java.lang.Throwable to include the thread dump after the normal stack trace.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

threadDump

private java.lang.String threadDump
Constructor Detail

AssertFailure

public AssertFailure(java.lang.String message,
                     java.lang.Throwable nestedError)
This constructor takes the pieces of information expected for each error.

Parameters:
message - the message associated with the error.
nestedError - 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.

AssertFailure

public AssertFailure(java.lang.String message)
This constructor takes the just the message for this error.

Parameters:
message - the message associated with the error.

AssertFailure

public AssertFailure()
This constructor expects no arguments or nested error.

Method Detail

getThreadDump

public java.lang.String getThreadDump()
Returns the thread dump stored in this AssertFailure as a string.

Returns:
- thread dump string.

printStackTrace

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

Overrides:
printStackTrace in class java.lang.Throwable

printStackTrace

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

Overrides:
printStackTrace in class java.lang.Throwable

printStackTrace

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

Overrides:
printStackTrace in class java.lang.Throwable

dumpThreads

private java.lang.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:
stack traces for all live threads as a string or an error message.

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.