Package gnu.jel.debug
Class Debug
java.lang.Object
gnu.jel.debug.Debug
This class used for incorporating internal checks and
assertions into the code.
None of these functions does anything if Debug.enabled is false.
If you really want to throw ALL debug messages from the final, compiler generated, code -- wrap calls to Debug methods into the if statement, checking Debug.enabled constant. As shown in the example :
None of these functions does anything if Debug.enabled is false.
If you really want to throw ALL debug messages from the final, compiler generated, code -- wrap calls to Debug methods into the if statement, checking Debug.enabled constant. As shown in the example :
import cz.fzu.metlov.jel.*; ..... BLA BLA BLA ... if (Debug.enabled) { Debug.println("I want this message to disappear in the optimized version"); Debug.check(foo==superTimeConsumingFunction(bar), "I do not want to evaluate superTimeConsumingFunction(), when optimized."); };
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
Determines if debugging is enabled in current compilation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final void
check
(boolean condition) Checks for the condition.static final void
Checks for the condition.static final void
Prints a line of the debug output.static final void
Reports an exception, which should not occur(i.e.static final void
reportThrowable
(Throwable t, String message) Reports an exception, which should not occur(i.e.
-
Field Details
-
enabled
public static final boolean enabledDetermines if debugging is enabled in current compilation.- See Also:
-
-
Constructor Details
-
Debug
public Debug()
-
-
Method Details
-
println
Prints a line of the debug output. The resulting line goes to System.err and is prefixed by "[DEBUG] ".- Parameters:
message
- message to print.
-
check
Checks for the condition. If condition is false this function prints a given message to the System.err along with the stack trace.- Parameters:
condition
- is the condition to check.message
- is the message to print if condition is false.
-
check
public static final void check(boolean condition) Checks for the condition. If condition is false this function prints a "Assertion failed." to the System.err along with the stack trace.- Parameters:
condition
- is the condition to check.
-
reportThrowable
Reports an exception, which should not occur(i.e. handled improperly).- Parameters:
t
- is what was thrown.message
- is algorithm specific message.
-
reportThrowable
Reports an exception, which should not occur(i.e. handled improperly).- Parameters:
t
- is what was thrown.
-