Revision: 8380
Author: sco...@google.com
Date: Tue Jul 13 15:21:54 2010
Log: Implement GWT.isProdMode()
http://gwt-code-reviews.appspot.com/692801/show
Review by: tobyr
http://code.google.com/p/google-web-toolkit/source/detail?r=8380
Modified:
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
/trunk/dev/core/test/com/google/gwt/dev/jjs/JavaAstConstructor.java
/trunk/user/src/com/google/gwt/core/client/GWT.java
/trunk/user/test/com/google/gwt/core/client/GWTTest.java
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
Thu Jul 8 08:08:57 2010
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
Tue Jul 13 15:21:54 2010
@@ -473,11 +473,14 @@
}
}
- // Reimplement GWT.isClient() and GWT.isScript() to return true
+ // Reimplement GWT.isClient(), GWT.isProdMode(), GWT.isScript().
if (currentClass == program.getIndexedType("GWT")) {
JMethod method = program.getIndexedMethod("GWT.isClient");
implementMethod(method, program.getLiteralBoolean(true));
+ method = program.getIndexedMethod("GWT.isProdMode");
+ implementMethod(method, program.getLiteralBoolean(true));
+
method = program.getIndexedMethod("GWT.isScript");
implementMethod(method, program.getLiteralBoolean(true));
}
=======================================
--- /trunk/dev/core/test/com/google/gwt/dev/jjs/JavaAstConstructor.java Thu
Jun 24 15:39:22 2010
+++ /trunk/dev/core/test/com/google/gwt/dev/jjs/JavaAstConstructor.java Tue
Jul 13 15:21:54 2010
@@ -118,6 +118,7 @@
code.append("package com.google.gwt.core.client;\n");
code.append("public final class GWT {\n");
code.append(" public boolean isClient() { return true; };\n");
+ code.append(" public boolean isProdMode() { return true; };\n");
code.append(" public boolean isScript() { return true; };\n");
code.append(" public static void runAsync(RunAsyncCallback
callback) { }\n");
code.append(" public static void runAsync(Class<?> name,
RunAsyncCallback callback) { }\n");
=======================================
--- /trunk/user/src/com/google/gwt/core/client/GWT.java Fri Mar 19 08:12:41
2010
+++ /trunk/user/src/com/google/gwt/core/client/GWT.java Tue Jul 13 15:21:54
2010
@@ -182,6 +182,16 @@
// Replaced with "true" by GWT compiler.
return sGWTBridge != null && sGWTBridge.isClient();
}
+
+ /**
+ * Returns <code>true</code> when running in production mode. Returns
+ * <code>false</code> when running either in development mode, or when
running
+ * in a plain JVM.
+ */
+ public static boolean isProdMode() {
+ // Replaced with "true" by GWT compiler.
+ return false;
+ }
/**
* Determines whether or not the running program is script or bytecode.
=======================================
--- /trunk/user/test/com/google/gwt/core/client/GWTTest.java Tue May 13
17:51:58 2008
+++ /trunk/user/test/com/google/gwt/core/client/GWTTest.java Tue Jul 13
15:21:54 2010
@@ -30,6 +30,7 @@
}-*/;
private static void jvmTests() {
+ assertFalse(GWT.isProdMode());
assertFalse(GWT.isScript());
try {
canCallNativeMethod();
@@ -74,6 +75,20 @@
assertTrue(GWT.isClient());
assertTrue(canCallNativeMethod());
}
+
+ @SuppressWarnings("unused")
+ public void testIsProdMode() {
+ if (GWT.isScript()) {
+ assertTrue(GWT.isProdMode());
+ }
+ try {
+ double d = seven / zero;
+ if (!GWT.isProdMode()) {
+ fail("Expected ArithmeticException");
+ }
+ } catch (ArithmeticException expected) {
+ }
+ }
@SuppressWarnings("unused")
public void testIsScript() {
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors