Reviewers: tobyr,


Please review this at http://gwt-code-reviews.appspot.com/692801/show

Affected files:
  M dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
  M dev/core/test/com/google/gwt/dev/jjs/JavaAstConstructor.java
  M user/src/com/google/gwt/core/client/GWT.java
  M user/test/com/google/gwt/core/client/GWTTest.java


Index: dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java index 11970fc0a1ff4d5d3e945093d41274b8801e0a0b..1e06fa18dd4b5e022529fb18ef79215299714ccc 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
@@ -473,11 +473,14 @@ public class GenerateJavaAST {
           }
         }

-        // 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));
         }
Index: dev/core/test/com/google/gwt/dev/jjs/JavaAstConstructor.java
diff --git a/dev/core/test/com/google/gwt/dev/jjs/JavaAstConstructor.java b/dev/core/test/com/google/gwt/dev/jjs/JavaAstConstructor.java index a5b5e96943af8e133d28544382c2fb6ad47cdc7c..9b3d03069296a6fde76be28e36e8234ee7586db3 100644
--- a/dev/core/test/com/google/gwt/dev/jjs/JavaAstConstructor.java
+++ b/dev/core/test/com/google/gwt/dev/jjs/JavaAstConstructor.java
@@ -118,6 +118,7 @@ public class JavaAstConstructor {
       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");
Index: user/src/com/google/gwt/core/client/GWT.java
diff --git a/user/src/com/google/gwt/core/client/GWT.java b/user/src/com/google/gwt/core/client/GWT.java index 71a70ec153dd2aba82729b103e1d6441966ea2b3..5589614fc8777254b1bed584bf0f8fcf48574345 100644
--- a/user/src/com/google/gwt/core/client/GWT.java
+++ b/user/src/com/google/gwt/core/client/GWT.java
@@ -184,6 +184,16 @@ public final class GWT {
   }

   /**
+   * 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.
    */
   public static boolean isScript() {
Index: user/test/com/google/gwt/core/client/GWTTest.java
diff --git a/user/test/com/google/gwt/core/client/GWTTest.java b/user/test/com/google/gwt/core/client/GWTTest.java index 8f10ab0f681e084582ea2285df388883b14d5947..1d7883fdb0d02694ff91e7ad7bd8a0f7092403e0 100644
--- a/user/test/com/google/gwt/core/client/GWTTest.java
+++ b/user/test/com/google/gwt/core/client/GWTTest.java
@@ -30,6 +30,7 @@ public class GWTTest extends GWTTestCase {
   }-*/;

   private static void jvmTests() {
+    assertFalse(GWT.isProdMode());
     assertFalse(GWT.isScript());
     try {
       canCallNativeMethod();
@@ -76,6 +77,20 @@ public class GWTTest extends GWTTestCase {
   }

   @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() {
     try {
       double d = seven / zero;


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to