"

2013 FRC Java API

"

com.sun.squawk.util
Class Assert

java.lang.Object
  extended by com.sun.squawk.util.Assert

public class Assert
extends Object

Provides support for assertions that can be removed on demand in order for building a release version. If the preprocessor is running with showLineNumbers=true, it will call the versions of these methods that take a filename and linenumber argument.

Version:
1.00

Field Summary
static boolean ASSERT_ALWAYS_IS_FATAL
          Whether Assert.always is a fatal error or throws an exception (usually TRUE)
static boolean ASSERTS_ENABLED
          Whether assertions are included in the bytecodes or not.
static boolean SHOULD_NOT_REACH_HERE_ALWAYS_ENABLED
          Flag to always enable shouldNotReachHere().
 
Method Summary
static void always(boolean cond)
          Asserts that the specified condition is true.
static void always(boolean cond, String msg)
          Asserts that the specified condition is true.
static void always(boolean cond, String filename, int lineno)
           
static void always(boolean cond, String msg, String filename, int lineno)
           
static RuntimeException shouldNotReachHere()
          Asserts that the compiler should never reach this point.
static RuntimeException shouldNotReachHere(String msg)
          Asserts that the compiler should never reach this point.
static RuntimeException shouldNotReachHere(String filename, int lineno)
           
static RuntimeException shouldNotReachHere(String msg, String filename, int lineno)
           
static RuntimeException shouldNotReachHereFatal()
          Asserts that the compiler should never reach this point.
static RuntimeException shouldNotReachHereFatal(String msg)
          Asserts that the compiler should never reach this point.
static RuntimeException shouldNotReachHereFatal(String filename, int lineno)
           
static RuntimeException shouldNotReachHereFatal(String msg, String filename, int lineno)
           
static void that(boolean cond)
          Asserts that the specified condition is true.
static void that(boolean cond, String msg)
          Asserts that the specified condition is true.
static void that(boolean cond, String filename, int lineno)
           
static void that(boolean cond, String msg, String filename, int lineno)
           
static void thatFatal(boolean cond)
          Asserts that the specified condition is true.
static void thatFatal(boolean cond, String msg)
          Asserts that the specified condition is true.
static void thatFatal(boolean cond, String filename, int lineno)
           
static void thatFatal(boolean cond, String msg, String filename, int lineno)
           
protected static void throwAssertFailedException(String message)
          Create one centralized place where an exception is thrown in case of Assert failure.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASSERTS_ENABLED

public static final boolean ASSERTS_ENABLED
Whether assertions are included in the bytecodes or not.

See Also:
Constant Field Values

SHOULD_NOT_REACH_HERE_ALWAYS_ENABLED

public static final boolean SHOULD_NOT_REACH_HERE_ALWAYS_ENABLED
Flag to always enable shouldNotReachHere().

See Also:
Constant Field Values

ASSERT_ALWAYS_IS_FATAL

public static final boolean ASSERT_ALWAYS_IS_FATAL
Whether Assert.always is a fatal error or throws an exception (usually TRUE)

See Also:
Constant Field Values
Method Detail

throwAssertFailedException

protected static void throwAssertFailedException(String message)
                                          throws NotInlinedPragma
Create one centralized place where an exception is thrown in case of Assert failure. Makes it easier to place a single breakpoint and debug.

Parameters:
message -
Throws:
NotInlinedPragma

that

public static void that(boolean cond,
                        String msg)
Asserts that the specified condition is true. If the condition is false, a RuntimeException is thrown with the specified message.

Parameters:
cond - condition to be tested
msg - message that explains the failure

that

public static void that(boolean cond,
                        String msg,
                        String filename,
                        int lineno)

that

public static void that(boolean cond)
Asserts that the specified condition is true. If the condition is false, a RuntimeException is thrown.

Parameters:
cond - condition to be tested

that

public static void that(boolean cond,
                        String filename,
                        int lineno)

shouldNotReachHere

public static RuntimeException shouldNotReachHere(String msg)
                                           throws NotInlinedPragma
Asserts that the compiler should never reach this point.

Parameters:
msg - message that explains the failure
Returns:
a null RuntimeException so that constructions such as throw !Assert.SHOULD_NOT_REACH_HERE_ALWAYS_ENABLED ? (RuntimeException)null : Assert.shouldNotReachHere() will be legal and thus avoid the need to return meaningless values from functions that have failed.
Throws:
NotInlinedPragma

shouldNotReachHere

public static RuntimeException shouldNotReachHere(String msg,
                                                  String filename,
                                                  int lineno)
                                           throws NotInlinedPragma
Throws:
NotInlinedPragma

shouldNotReachHere

public static RuntimeException shouldNotReachHere()
Asserts that the compiler should never reach this point.

Returns:
a null RuntimeException so that constructions such as throw !Assert.SHOULD_NOT_REACH_HERE_ALWAYS_ENABLED ? (RuntimeException)null : Assert.shouldNotReachHere() will be legal and thus avoid the need to return meaningless values from functions that have failed.

shouldNotReachHere

public static RuntimeException shouldNotReachHere(String filename,
                                                  int lineno)

thatFatal

public static void thatFatal(boolean cond,
                             String msg)
Asserts that the specified condition is true. If the condition is false the specified message is displayed and the VM is halted.

Parameters:
cond - condition to be tested
msg - message that explains the failure

thatFatal

public static void thatFatal(boolean cond,
                             String msg,
                             String filename,
                             int lineno)

thatFatal

public static void thatFatal(boolean cond)
Asserts that the specified condition is true. If the condition is false the VM is halted.

Parameters:
cond - condition to be tested

thatFatal

public static void thatFatal(boolean cond,
                             String filename,
                             int lineno)

shouldNotReachHereFatal

public static RuntimeException shouldNotReachHereFatal(String msg)
Asserts that the compiler should never reach this point.

Parameters:
msg - message that explains the failure
Returns:
a null RuntimeException so that constructions such as throw !Assert.SHOULD_NOT_REACH_HERE_ALWAYS_ENABLED ? (RuntimeException)null : Assert.shouldNotReachHere() will be legal and thus avoid the need to return meaningless values from functions that have failed.

shouldNotReachHereFatal

public static RuntimeException shouldNotReachHereFatal(String msg,
                                                       String filename,
                                                       int lineno)

shouldNotReachHereFatal

public static RuntimeException shouldNotReachHereFatal()
Asserts that the compiler should never reach this point.

Returns:
a null RuntimeException so that constructions such as throw !Assert.SHOULD_NOT_REACH_HERE_ALWAYS_ENABLED ? (RuntimeException)null : Assert.shouldNotReachHere() will be legal and thus avoid the need to return meaningless values from functions that have failed.

shouldNotReachHereFatal

public static RuntimeException shouldNotReachHereFatal(String filename,
                                                       int lineno)

always

public static void always(boolean cond,
                          String msg)
Asserts that the specified condition is true. If the condition is false the specified message is displayed and the VM is halted. Calls to this method are never removed by the Squawk pre-processor and as such should only be placed in frequent execution paths absolutely necessary.

Parameters:
cond - condition to be tested
msg - message that explains the failure

always

public static void always(boolean cond,
                          String msg,
                          String filename,
                          int lineno)

always

public static void always(boolean cond)
Asserts that the specified condition is true. If the condition is false the VM is halted. Calls to this method are never removed by the Squawk pre-processor and as such should only be placed in frequent execution paths absolutely necessary.

Parameters:
cond - condition to be tested

always

public static void always(boolean cond,
                          String filename,
                          int lineno)

"

2013 FRC Java API

"

"
For updated information see the Java FRC site
"