|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hdcookbook.grin.util.Debug
public class Debug
Debugging support. It is expected that in a real project, the file Debug.java will be physically replaced with a different source code file that * implements the same public API. For a deploy build, it should * have ASSERT set false, and LEVEL set to 0. For a debug build, it will almost certainly send the debug output somewhere more useful than stderr/stdout.
Replacing a source file and re-building a library may be unfamiliar to some Java programmers, but C programmers will instantly recognize this as the assert.h idiom. This way of doing things has fallen out of favor for desktop programming, but it is this author's opinion that the efficiency gain from stripping out assertions and debug statements at compile time is worth it in an embedded environment like Blu-ray.
The GrinXlet application framework (in xlets/GrinXlet) does as is outlined here -- the GrinXlet build excludes the version of Debug.java you're reading now, and replaces it with either a debug version (that sends debug info to a special screen you can access via the remote control, and that you can telnet to the player to get), and a deploy version (that sets the constants so that the compiler strips out debug and assertions).
Some people like to solve this problem by having a build system that edits one or two key source files, to change the value of some key constants (like ASSERT and LEVEL in this class) depending on the build. That's a great technique too, but in any case you'll need to write your own version of Debug.java if you want to go that way.
Note that the GRIN library was written assuming that the deploy version of an xlet will be built with ASSERT set false and LEVEL set to 0. It contains many assertions, some of which are computationally expensive. Consider, for example, com.hdcookbook.grin.features.Group.java, which has an assertion that spans a couple of screens and creates a HashSet.
More discussion of this can be found in Issue 164
Field Summary | |
---|---|
static boolean |
ASSERT
Variable to say that assertions are enabled. |
static int |
LEVEL
Debug level. |
static boolean |
PROFILE
Variable to say if time profiling is enabled. |
static boolean |
PROFILE_ANIMATION
Variable to say if animation profiling is enabled. |
static boolean |
PROFILE_SETUP
Variable to say if setup profiling is enabled. |
Method Summary | |
---|---|
static void |
assertFail()
Called on assertion failure. |
static void |
assertFail(java.lang.String msg)
Called on assertion failure. |
static void |
println()
|
static void |
println(java.lang.Object o)
|
static void |
printStackTrace(java.lang.Throwable t)
Print a stack trace to the debug log, if Debug.LEVEL > 0. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean ASSERT
Usage:
if (Debug.ASSERT && some condition that should be false) { Debug.println(something interesting); }
Note that JDK 1.4's assertion facility can't be used for Blu-Ray, since PBP 1.0 is based on JDK 1.3.
public static final int LEVEL
public static final boolean PROFILE
Profile
,
Constant Field Valuespublic static final boolean PROFILE_ANIMATION
Profile
,
Constant Field Valuespublic static final boolean PROFILE_SETUP
Profile
,
Constant Field ValuesMethod Detail |
---|
public static void println()
public static void println(java.lang.Object o)
public static void assertFail(java.lang.String msg)
public static void assertFail()
public static void printStackTrace(java.lang.Throwable t)
Thread.dumpStack()
using this bit of code:
try { throw new RuntimeException("STACK BACKTRACE"); } catch (RuntimeException ex) { Debug.printStackTrace(ex); }
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |