Bug 1001063 - Add Assert class for debug assertions in Java code r=blassey

This commit is contained in:
James Willcox 2014-04-25 13:45:52 -05:00
parent c58de9ee99
commit 83ee406fd2
4 changed files with 50 additions and 0 deletions

View File

@ -157,4 +157,11 @@ public class AppConstants {
#else
false;
#endif
public static final boolean DEBUG_BUILD =
#ifdef MOZ_DEBUG
true;
#else
false;
#endif
}

View File

@ -0,0 +1,41 @@
package org.mozilla.gecko;
public class Assert
{
private Assert() {}
public static void equals(Object a, Object b)
{
equals(a, b, null);
}
public static void equals(Object a, Object b, String message)
{
Assert.isTrue(a.equals(b), message);
}
public static void isTrue(boolean a)
{
isTrue(a, null);
}
public static void isTrue(boolean a, String message)
{
if (!AppConstants.DEBUG_BUILD) {
return;
}
if (!a) {
throw new AssertException(message);
}
}
public static class AssertException extends RuntimeException
{
private static final long serialVersionUID = 0L;
public AssertException(String message) {
super(message);
}
}
}

View File

@ -40,6 +40,7 @@ DEFINES += \
-DMOZ_APP_BUILDID=$(MOZ_APP_BUILDID) \
-DMOZ_BUILD_TIMESTAMP=$(MOZ_BUILD_TIMESTAMP) \
-DUA_BUILDID=$(UA_BUILDID) \
-DMOZ_DEBUG=$(MOZ_DEBUG) \
$(NULL)
GARBAGE += \

View File

@ -116,6 +116,7 @@ gbjar.sources += [
'animation/ViewHelper.java',
'ANRReporter.java',
'AppNotificationClient.java',
'Assert.java',
'BaseGeckoInterface.java',
'BrowserApp.java',
'BrowserLocaleManager.java',