Rolling back r8752 and r8762 for now.

This change is tickling a bug in some JS engines, for some apps.


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@8804 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java b/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java
index 8acc0f9..efafcf6 100644
--- a/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java
+++ b/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java
@@ -328,7 +328,9 @@
    *
    * @return any newly generated artifacts since the last call
    */
-  public final ArtifactSet finish(TreeLogger logger) {
+  public final ArtifactSet finish(TreeLogger logger)
+      throws UnableToCompleteException {
+
     abortUncommittedResources(logger);
 
     // Process pending generated types.
@@ -359,6 +361,16 @@
         compilationState.addGeneratedCompilationUnits(logger,
             committedGeneratedCups);
       }
+
+      // Make sure all generated types can be found in TypeOracle.
+      TypeOracle typeOracle = getTypeOracle();
+      for (String genTypeName : genTypeNames) {
+        if (typeOracle.findType(genTypeName) == null) {
+          String msg = "Unable to find recently-generated type '" + genTypeName;
+          logger.log(TreeLogger.ERROR, msg, null);
+          throw new UnableToCompleteException();
+        }
+      }
       return newlyGeneratedArtifacts;
     } finally {
 
diff --git a/dev/core/src/com/google/gwt/dev/jdt/WebModeCompilerFrontEnd.java b/dev/core/src/com/google/gwt/dev/jdt/WebModeCompilerFrontEnd.java
index 62c9cbe..57c017f 100644
--- a/dev/core/src/com/google/gwt/dev/jdt/WebModeCompilerFrontEnd.java
+++ b/dev/core/src/com/google/gwt/dev/jdt/WebModeCompilerFrontEnd.java
@@ -136,7 +136,11 @@
     }
 
     if (doFinish) {
-      rebindPermOracle.getGeneratorContext().finish(logger);
+      try {
+        rebindPermOracle.getGeneratorContext().finish(logger);
+      } catch (UnableToCompleteException e) {
+        throw new RuntimeException("Unable to commit generated files", e);
+      }
     }
 
     // Sanity check all rebind answers.
diff --git a/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java b/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java
index cdc8a18..98d65e7 100644
--- a/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java
+++ b/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java
@@ -244,7 +244,11 @@
     testTryCreateResource_commitNotCalled();
 
     // Now call finish() again to make sure nothing blows up.
-    genCtx.finish(mockLogger);
+    try {
+      genCtx.finish(mockLogger);
+    } catch (UnableToCompleteException e) {
+      fail("finish() failed; it should support safely being called any number of times");
+    }
   }
 
   public void testTryCreateResource_normalCompletionWithoutSubDir()
diff --git a/user/src/com/google/gwt/user/client/rpc/core/java/util/Arrays.java b/user/src/com/google/gwt/user/client/rpc/core/java/util/Arrays.java
index a3336ef..a5145ea 100644
--- a/user/src/com/google/gwt/user/client/rpc/core/java/util/Arrays.java
+++ b/user/src/com/google/gwt/user/client/rpc/core/java/util/Arrays.java
@@ -31,11 +31,6 @@
    * Custom field serializer for {@link java.util.Arrays$ArrayList}.
    */
   public static final class ArrayList_CustomFieldSerializer {
-
-    public static Class<?> concreteType() {
-      return java.util.Arrays.asList().getClass();
-    }
-
     /*
      * Note: the reason this implementation differs from that of a standard List
      * (which serializes a number and then each element) is the requirement that
diff --git a/user/src/com/google/gwt/user/client/rpc/core/java/util/Collections.java b/user/src/com/google/gwt/user/client/rpc/core/java/util/Collections.java
index 225bf3b..6984e04 100644
--- a/user/src/com/google/gwt/user/client/rpc/core/java/util/Collections.java
+++ b/user/src/com/google/gwt/user/client/rpc/core/java/util/Collections.java
@@ -33,10 +33,6 @@
    */
   public static final class EmptyList_CustomFieldSerializer {
 
-    public static Class<?> concreteType() {
-      return java.util.Collections.emptyList().getClass();
-    }
-
     @SuppressWarnings({"unused", "unchecked"})
     public static void deserialize(SerializationStreamReader streamReader,
         List instance) throws SerializationException {
@@ -61,10 +57,6 @@
    */
   public static final class EmptyMap_CustomFieldSerializer {
 
-    public static Class<?> concreteType() {
-      return java.util.Collections.emptyMap().getClass();
-    }
-
     @SuppressWarnings({"unused", "unchecked"})
     public static void deserialize(SerializationStreamReader streamReader,
         Map instance) throws SerializationException {
@@ -89,10 +81,6 @@
    */
   public static final class EmptySet_CustomFieldSerializer {
 
-    public static Class<?> concreteType() {
-      return java.util.Collections.emptySet().getClass();
-    }
-
     @SuppressWarnings({"unused", "unchecked"})
     public static void deserialize(SerializationStreamReader streamReader,
         Set instance) throws SerializationException {
@@ -117,10 +105,6 @@
    */
   public static final class SingletonList_CustomFieldSerializer {
 
-    public static Class<?> concreteType() {
-      return java.util.Collections.singletonList(null).getClass();
-    }
-
     @SuppressWarnings({"unused", "unchecked"})
     public static void deserialize(SerializationStreamReader streamReader,
         List instance) throws SerializationException {
diff --git a/user/src/com/google/gwt/user/client/rpc/impl/SerializerBase.java b/user/src/com/google/gwt/user/client/rpc/impl/SerializerBase.java
index 228f679..69f5361 100644
--- a/user/src/com/google/gwt/user/client/rpc/impl/SerializerBase.java
+++ b/user/src/com/google/gwt/user/client/rpc/impl/SerializerBase.java
@@ -23,6 +23,7 @@
 import com.google.gwt.user.client.rpc.SerializationStreamReader;
 import com.google.gwt.user.client.rpc.SerializationStreamWriter;
 
+import java.util.IdentityHashMap;
 import java.util.Map;
 
 /**
@@ -34,7 +35,7 @@
 public abstract class SerializerBase implements Serializer {
 
   /**
-   * Used in JavaScript to map a type to a set of serialization functions.
+   * Represents a collection of functions that perform type-specific functions.
    */
   protected static final class MethodMap extends JavaScriptObject {
     protected MethodMap() {
@@ -64,89 +65,103 @@
     }-*/;
   }
 
-  private final Map<String, TypeHandler> methodMapJava;
+  private static final Map<JsArrayString, Map<Class<?>, String>> hostedSignatureMaps;
 
-  private final MethodMap methodMapNative;
+  static {
+    if (GWT.isScript()) {
+      hostedSignatureMaps = null;
+    } else {
+      hostedSignatureMaps = new IdentityHashMap<JsArrayString, Map<Class<?>, String>>();
+    }
+  }
 
-  private final Map<Class<?>, String> signatureMapJava;
+  protected static final void registerMethods(MethodMap methodMap,
+      String signature, JsArray<JavaScriptObject> methods) {
+    assert signature != null : "signature";
+    assert methodMap.get(signature) == null : "Duplicate signature "
+        + signature;
 
-  private final JsArrayString signatureMapNative;
+    methodMap.put(signature, methods);
+  }
 
-  public SerializerBase(Map<String, TypeHandler> methodMapJava,
-      MethodMap methodMapNative, Map<Class<?>, String> signatureMapJava,
-      JsArrayString signatureMapNative) {
-    this.methodMapJava = methodMapJava;
-    this.methodMapNative = methodMapNative;
-    this.signatureMapJava = signatureMapJava;
-    this.signatureMapNative = signatureMapNative;
+  protected static final void registerSignature(JsArrayString signatureMap,
+      Class<?> clazz, String signature) {
+    assert clazz != null : "clazz";
+    assert signature != null : "signature";
+
+    if (GWT.isScript()) {
+      assert signatureMap.get(clazz.hashCode()) == null : "Duplicate signature "
+          + signature;
+      signatureMap.set(clazz.hashCode(), signature);
+
+    } else {
+      Map<Class<?>, String> subMap = getSubMap(signatureMap);
+
+      assert !subMap.containsKey(clazz);
+      subMap.put(clazz, signature);
+    }
+  }
+
+  /**
+   * Hashcodes in hosted mode are unpredictable. Each signature map is
+   * associated with a proper IdentityHashMap. This method should only be used
+   * in hosted mode.
+   */
+  private static Map<Class<?>, String> getSubMap(JsArrayString signatureMap) {
+    assert !GWT.isScript() : "Should only use this in hosted mode";
+    Map<Class<?>, String> subMap = hostedSignatureMaps.get(signatureMap);
+    if (subMap == null) {
+      subMap = new IdentityHashMap<Class<?>, String>();
+      hostedSignatureMaps.put(signatureMap, subMap);
+    }
+    return subMap;
   }
 
   public final void deserialize(SerializationStreamReader stream,
       Object instance, String typeSignature) throws SerializationException {
-    if (GWT.isScript()) {
-      check(typeSignature, 2);
-      methodMapNative.deserialize(stream, instance, typeSignature);
-    } else {
-      TypeHandler typeHandler = getTypeHandler(typeSignature);
-      typeHandler.deserialize(stream, instance);
-    }
+    check(typeSignature, 2);
+
+    getMethodMap().deserialize(stream, instance, typeSignature);
   }
 
   public final String getSerializationSignature(Class<?> clazz) {
     assert clazz != null : "clazz";
     if (GWT.isScript()) {
-      return signatureMapNative.get(clazz.hashCode());
+      return getSignatureMap().get(clazz.hashCode());
     } else {
-      return signatureMapJava.get(clazz);
+      return getSubMap(getSignatureMap()).get(clazz);
     }
   }
 
   public final Object instantiate(SerializationStreamReader stream,
       String typeSignature) throws SerializationException {
-    if (GWT.isScript()) {
-      check(typeSignature, 1);
-      return methodMapNative.instantiate(stream, typeSignature);
-    } else {
-      TypeHandler typeHandler = getTypeHandler(typeSignature);
-      return typeHandler.instantiate(stream);
-    }
+    check(typeSignature, 1);
+
+    return getMethodMap().instantiate(stream, typeSignature);
   }
 
   public final void serialize(SerializationStreamWriter stream,
       Object instance, String typeSignature) throws SerializationException {
-    if (GWT.isScript()) {
-      check(typeSignature, 3);
-      methodMapNative.serialize(stream, instance, typeSignature);
-    } else {
-      TypeHandler typeHandler = getTypeHandler(typeSignature);
-      typeHandler.serialize(stream, instance);
-    }
+    check(typeSignature, 3);
+
+    getMethodMap().serialize(stream, instance, typeSignature);
   }
 
+  protected abstract MethodMap getMethodMap();
+
+  protected abstract JsArrayString getSignatureMap();
+
   private void check(String typeSignature, int length)
       throws SerializationException {
     /*
      * Probably trying to serialize a type that isn't supposed to be
      * serializable.
      */
-    if (methodMapNative.get(typeSignature) == null) {
+    if (getMethodMap().get(typeSignature) == null) {
       throw new SerializationException(typeSignature);
     }
 
-    assert methodMapNative.get(typeSignature).length() >= length : "Not enough methods, expecting "
-        + length + " saw " + methodMapNative.get(typeSignature).length();
-  }
-
-  private TypeHandler getTypeHandler(String typeSignature)
-      throws SerializationException {
-    TypeHandler typeHandler = methodMapJava.get(typeSignature);
-    if (typeHandler == null) {
-      /*
-       * Probably trying to serialize a type that isn't supposed to be
-       * serializable.
-       */
-      throw new SerializationException(typeSignature);
-    }
-    return typeHandler;
+    assert getMethodMap().get(typeSignature).length() >= length : "Not enough methods, expecting "
+        + length + " saw " + getMethodMap().get(typeSignature).length();
   }
 }
diff --git a/user/src/com/google/gwt/user/client/rpc/impl/TypeHandler.java b/user/src/com/google/gwt/user/client/rpc/impl/TypeHandler.java
deleted file mode 100644
index 68a9cc0..0000000
--- a/user/src/com/google/gwt/user/client/rpc/impl/TypeHandler.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.user.client.rpc.impl;
-
-import com.google.gwt.user.client.rpc.SerializationException;
-import com.google.gwt.user.client.rpc.SerializationStreamReader;
-import com.google.gwt.user.client.rpc.SerializationStreamWriter;
-
-/**
- * An interface to serializer or deserialize objects of a particular type.
- */
-public interface TypeHandler {
-  void deserialize(SerializationStreamReader reader, Object object)
-      throws SerializationException;
-
-  Object instantiate(SerializationStreamReader reader)
-      throws SerializationException;
-
-  void serialize(SerializationStreamWriter writer, Object object)
-      throws SerializationException;
-}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/CustomFieldSerializerValidator.java b/user/src/com/google/gwt/user/rebind/rpc/CustomFieldSerializerValidator.java
index f4c81df..a38478e 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/CustomFieldSerializerValidator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/CustomFieldSerializerValidator.java
@@ -35,11 +35,6 @@
   private static final String NO_INSTANTIATE_METHOD = "Custom Field Serializer ''{0}'' does not define an instantiate method: ''public static {1} instantiate({2} reader)''; but ''{1}'' is not default instantiable";
   private static final String NO_SERIALIZE_METHOD = "Custom Field Serializer ''{0}'' does not define a serialize method: ''public static void serialize({1} writer,{2} instance)''";
   private static final String TOO_MANY_METHODS = "Custom Field Serializer ''{0}'' defines too many methods named ''{1}''; please define only one method with that name";
-  private static final String WRONG_CONCRETE_TYPE_RETURN = "Custom Field Serializer ''{0}'' returns the wrong type from ''concreteType''; return type must be ''java.lang.Class''";
-
-  public static JMethod getConcreteTypeMethod(JClassType serializer) {
-    return serializer.findMethod("concreteType", new JType[0]);
-  }
 
   public static JMethod getDeserializationMethod(JClassType serializer,
       JClassType serializee) {
@@ -161,17 +156,6 @@
       checkTooMany("instantiate", serializer, reasons);
     }
 
-    JMethod concreteTypeMethod = getConcreteTypeMethod(serializer);
-    if (concreteTypeMethod != null) {
-      if (!"java.lang.Class".equals(concreteTypeMethod.getReturnType().getQualifiedSourceName())) {
-        // Wrong return type.
-        reasons.add(MessageFormat.format(WRONG_CONCRETE_TYPE_RETURN,
-            serializer.getQualifiedSourceName()));
-      } else {
-        checkTooMany("concreteType", serializer, reasons);
-      }
-    }
-
     return reasons;
   }
 
diff --git a/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java b/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java
index 45ea1e5..cf8ac75 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java
@@ -144,7 +144,7 @@
 
     sb.append("new ");
     sb.append(array.getLeafType().getQualifiedSourceName());
-    sb.append("[size]");
+    sb.append("[rank]");
     for (int i = 0; i < array.getRank() - 1; ++i) {
       sb.append("[]");
     }
@@ -225,49 +225,6 @@
     }
   }
 
-  /**
-   * Writes an instantiate method. Examples:
-   * 
-   * <h2>Class</h2>
-   * 
-   * <pre>
-   * public static com.google.gwt.sample.client.Student instantiate(
-   *     SerializationStreamReader streamReader) throws SerializationException {
-   *   return new com.google.gwt.sample.client.Student();
-   * }
-   * </pre>
-   * 
-   * <h2>Class with private ctor</h2>
-   * 
-   * <pre>
-   * public static native com.google.gwt.sample.client.Student instantiate(
-   *     SerializationStreamReader streamReader) throws SerializationException /*-{
-   * return @com.google.gwt.sample.client.Student::new()();
-   * }-&#42;/;
-   * </pre>
-   * 
-   * <h2>Array</h2>
-   * 
-   * <pre>
-   * public static com.google.gwt.sample.client.Student[] instantiate(
-   *     SerializationStreamReader streamReader) throws SerializationException {
-   *   int size = streamReader.readInt();
-   *   return new com.google.gwt.sample.client.Student[size];
-   * }
-   * </pre>
-   * 
-   * <h2>Enum</h2>
-   * 
-   * <pre>
-   * public static com.google.gwt.sample.client.Role instantiate(
-   *     SerializationStreamReader streamReader) throws SerializationException {
-   *   int ordinal = streamReader.readInt();
-   *   com.google.gwt.sample.client.Role[] values = com.google.gwt.sample.client.Role.values();
-   *   assert (ordinal &gt;= 0 &amp;&amp; ordinal &lt; values.length);
-   *   return values[ordinal];
-   * }
-   * </pre>
-   */
   private void maybeWriteInstatiateMethod() {
     if (serializableClass.isEnum() == null
         && (serializableClass.isAbstract() || !serializableClass.isDefaultInstantiable())) {
@@ -310,7 +267,7 @@
     sourceWriter.indent();
 
     if (isArray != null) {
-      sourceWriter.println("int size = streamReader.readInt();");
+      sourceWriter.println("int rank = streamReader.readInt();");
       sourceWriter.println("return "
           + createArrayInstantiationExpression(isArray) + ";");
     } else if (isEnum != null) {
@@ -330,31 +287,6 @@
     sourceWriter.println();
   }
 
-  /**
-   * Write a {@link TypeHandler} for the class, used by Java.
-   * 
-   * <pre>
-   * public static class Handler implements
-   *     com.google.gwt.user.client.rpc.impl.TypeHandler {
-   *   public void deserialize(SerializationStreamReader reader, Object object)
-   *       throws SerializationException {
-   *     com.google.gwt.sample.client.Student_FieldSerializer.deserialize(
-   *         reader, (com.google.gwt.sample.client.Student) object);
-   *   }
-   * 
-   *   public Object instantiate(SerializationStreamReader reader)
-   *       throws SerializationException {
-   *     return com.google.gwt.sample.client.Student_FieldSerializer.instantiate(reader);
-   *   }
-   * 
-   *   public void serialize(SerializationStreamWriter writer, Object object)
-   *       throws SerializationException {
-   *     com.google.gwt.sample.client.Student_FieldSerializer.serialize(
-   *         writer, (com.google.gwt.sample.client.Student) object);
-   *   }
-   * }
-   * </pre>
-   */
   private void maybeWriteTypeHandlerClass() {
     if (serializableClass.isEnum() == null && serializableClass.isAbstract()) {
       /*
@@ -586,16 +518,6 @@
     }
   }
 
-  /**
-   * Writes the concreteType method, for loading a Java Class -> TypeHandler
-   * map.
-   * 
-   * <pre>
-   * public static Class&lt;?&gt; concreteType() {
-   *   return com.google.gwt.sample.client.Student.class;
-   * }
-   * </pre>
-   */
   private void writeConcreteTypeMethod() {
     if (customFieldSerializer != null
         && CustomFieldSerializerValidator.getConcreteTypeMethod(customFieldSerializer) != null) {
diff --git a/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java b/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
index c01b64d..83a2ffd 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
@@ -601,8 +601,7 @@
       throws UnableToCompleteException {
     TypeSerializerCreator tsc = new TypeSerializerCreator(logger,
         typesSentFromBrowser, typesSentToBrowser, context,
-        SerializationUtils.getTypeSerializerQualifiedName(serviceIntf),
-        SerializationUtils.getTypeSerializerSimpleName(serviceIntf));
+        SerializationUtils.getTypeSerializerQualifiedName(serviceIntf));
     tsc.realize(logger);
 
     typeStrings = new HashMap<JType, String>(tsc.getTypeStrings());
diff --git a/user/src/com/google/gwt/user/rebind/rpc/SerializationUtils.java b/user/src/com/google/gwt/user/rebind/rpc/SerializationUtils.java
index 22873c3..3d33e05 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/SerializationUtils.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/SerializationUtils.java
@@ -105,7 +105,24 @@
 
     assert (type.isClassOrInterface() != null || type.isArray() != null);
     JClassType classType = (JClassType) type;
-    return getStandardSerializerName(classType);
+    String[] name = Shared.synthesizeTopLevelClassName(classType,
+        SerializationUtils.GENERATED_FIELD_SERIALIZER_SUFFIX);
+    if (name[0].length() > 0) {
+      String serializerName = name[0] + "." + name[1];
+      if (SerializableTypeOracleBuilder.isInStandardJavaPackage(type.getQualifiedSourceName())) {
+        /*
+         * Don't generate code into java packages. If you do hosted mode
+         * CompilingClassLoader will fail to resolve references to the generated
+         * code.
+         */
+        serializerName = "com.google.gwt.user.client.rpc.core."
+            + serializerName;
+      }
+
+      return serializerName;
+    } else {
+      return name[1];
+    }
   }
 
   /**
@@ -129,30 +146,6 @@
   }
 
   /**
-   * Returns the name of the generated field serializer.
-   */
-  static String getStandardSerializerName(JClassType classType) {
-    String[] name = Shared.synthesizeTopLevelClassName(classType,
-        SerializationUtils.GENERATED_FIELD_SERIALIZER_SUFFIX);
-    if (name[0].length() > 0) {
-      String serializerName = name[0] + "." + name[1];
-      if (SerializableTypeOracleBuilder.isInStandardJavaPackage(classType.getQualifiedSourceName())) {
-        /*
-         * Don't generate code into java packages. If you do hosted mode
-         * CompilingClassLoader will fail to resolve references to the generated
-         * code.
-         */
-        serializerName = "com.google.gwt.user.client.rpc.core."
-            + serializerName;
-      }
-
-      return serializerName;
-    } else {
-      return name[1];
-    }
-  }
-
-  /**
    * Returns the qualified name of the type serializer class for the given
    * service interface.
    * 
diff --git a/user/src/com/google/gwt/user/rebind/rpc/Shared.java b/user/src/com/google/gwt/user/rebind/rpc/Shared.java
index 03baca4..57617ea 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/Shared.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/Shared.java
@@ -119,7 +119,7 @@
     JType leafType = type.getLeafType();
     if (leafType.isPrimitive() != null) {
       className = leafType.getSimpleSourceName();
-      packageName = "com.google.gwt.user.client.rpc.core";
+      packageName = "";
     } else {
       JClassType classOrInterface = leafType.isClassOrInterface();
       assert (classOrInterface != null);
diff --git a/user/src/com/google/gwt/user/rebind/rpc/TypeSerializerCreator.java b/user/src/com/google/gwt/user/rebind/rpc/TypeSerializerCreator.java
index d73a5d9..7487759 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/TypeSerializerCreator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/TypeSerializerCreator.java
@@ -29,6 +29,7 @@
 import com.google.gwt.core.ext.typeinfo.JType;
 import com.google.gwt.core.ext.typeinfo.TypeOracle;
 import com.google.gwt.dev.javac.TypeOracleMediator;
+import com.google.gwt.user.client.rpc.SerializationException;
 import com.google.gwt.user.client.rpc.SerializationStreamReader;
 import com.google.gwt.user.client.rpc.SerializationStreamWriter;
 import com.google.gwt.user.client.rpc.impl.SerializerBase;
@@ -274,6 +275,9 @@
 
     composerFactory.addImport(GWT.class.getName());
     composerFactory.addImport(JsArrayString.class.getName());
+    composerFactory.addImport(SerializationException.class.getName());
+    composerFactory.addImport(SerializationStreamReader.class.getName());
+    composerFactory.addImport(SerializationStreamWriter.class.getName());
     composerFactory.addImport(TypeHandler.class.getName());
     composerFactory.addImport(HashMap.class.getName());
     composerFactory.addImport(Map.class.getName());
@@ -301,15 +305,6 @@
         customSerializer, (JClassType) type) != null;
   }
 
-  /**
-   * Writes constructor.
-   * 
-   * <pre>
-   * public SchoolCalendarService_TypeSerializer() {
-   *   super(methodMapJava, methodMapNative, signatureMapJava, signatureMapNative);
-   * }
-   * </pre>
-   */
   private void writeConstructor() {
     srcWriter.println("public " + typeSerializerSimpleName + "() {");
     srcWriter.indentln("super(methodMapJava, methodMapNative, signatureMapJava, signatureMapNative);");
@@ -317,21 +312,6 @@
     srcWriter.println();
   }
 
-  /**
-   * Writes a method to produce a map of type string -> {@link TypeHandler}
-   * for Java.
-   * 
-   * <pre>
-   * private static Map&lt;String, TypeHandler&gt; loadMethodsJava() {
-   *   Map&lt;String, TypeHandler&gt; result = new HashMap&lt;String, TypeHandler&gt;();
-   *   result.put(
-   *       &quot;java.lang.String/2004016611&quot;,
-   *       new com.google.gwt.user.client.rpc.core.java.lang.String_FieldSerializer.Handler());
-   *   ...
-   *   return result;
-   * }
-   * </pre>
-   */
   private void writeLoadMethodsJava() {
     srcWriter.println("private static Map<String, TypeHandler> loadMethodsJava() {");
     srcWriter.indent();
@@ -363,22 +343,6 @@
     srcWriter.println();
   }
 
-  /**
-   * Writes a method to produce a native map of type string -> handler funcs.
-   * 
-   * <pre>
-   * private static native MethodMap loadMethodsNative() /&#42;-{
-   *     var result = {};
-   *     result["java.lang.String/2004016611"] = [
-   *         @com.google.gwt.user.client.rpc.core.java.lang.String_CustomFieldSerializer::instantiate(Lcom/google/gwt/user/client/rpc/SerializationStreamReader;),
-   *         @com.google.gwt.user.client.rpc.core.java.lang.String_CustomFieldSerializer::deserialize(Lcom/google/gwt/user/client/rpc/SerializationStreamReader;Ljava/lang/String;),
-   *         @com.google.gwt.user.client.rpc.core.java.lang.String_CustomFieldSerializer::serialize(Lcom/google/gwt/user/client/rpc/SerializationStreamWriter;Ljava/lang/String;)
-   *       ];
-   *     ...
-   *     return result;
-   *   }-&#42;/;
-   * </pre>
-   */
   private void writeLoadMethodsNative() {
     srcWriter.println("private static native MethodMap loadMethodsNative() /*-{");
     srcWriter.indent();
@@ -431,20 +395,6 @@
     srcWriter.println();
   }
 
-  /**
-   * Writes a method to produce a map of class to type string for Java.
-   * 
-   * <pre>
-   * private static Map&lt;Class&lt;?&gt;, String&gt; loadSignaturesJava() {
-   *   Map&lt;Class&lt;?&gt;, String&gt; result = new HashMap&lt;Class&lt;?&gt;, String&gt;();
-   *   result.put(
-   *       com.google.gwt.user.client.rpc.core.java.lang.String_FieldSerializer.concreteType(),
-   *       &quot;java.lang.String/2004016611&quot;);
-   *   ...
-   *   return result;
-   * }
-   * </pre>
-   */
   private void writeLoadSignaturesJava() {
     srcWriter.println("private static Map<Class<?>, String> loadSignaturesJava() {");
     srcWriter.indent();
@@ -485,18 +435,6 @@
     srcWriter.println();
   }
 
-  /**
-   * Writes a method to produce a native map of system hash code to type string.
-   * 
-   * <pre>
-   * private static native JsArrayString loadSignaturesNative() /*-{
-   *   var result = [];
-   *   result[@com.google.gwt.core.client.impl.Impl::getHashCode(Ljava/lang/Object;)(@java.lang.String::class)] = &quot;java.lang.String/2004016611&quot;;
-   *   ...
-   *   return result;
-   * }-&#42;/;
-   * </pre>
-   */
   private void writeLoadSignaturesNative() {
     srcWriter.println("private static native JsArrayString loadSignaturesNative() /*-{");
     srcWriter.indent();
@@ -543,16 +481,6 @@
     srcWriter.println();
   }
 
-  /**
-   * Writes the class's static fields.
-   * 
-   * <pre>
-   * private static final Map&lt;String, TypeHandler&gt; methodMapJava;
-   * private static final MethodMap methodMapNative;
-   * private static final Map&lt;Class&lt;?&gt;, String&gt; signatureMapJava;
-   * private static final JsArrayString signatureMapNative;
-   * </pre>
-   */
   private void writeStaticFields() {
     srcWriter.println("private static final Map<String, TypeHandler> methodMapJava;");
     srcWriter.println("private static final MethodMap methodMapNative;");
@@ -561,25 +489,6 @@
     srcWriter.println();
   }
 
-  /**
-   * Statically initializes the class fields either for script or JVM.
-   * 
-   * <pre>
-   * static {
-   *   if (GWT.isScript()) {
-   *     methodMapJava = null;
-   *     methodMapNative = loadMethodsNative();
-   *     signatureMapJava = null;
-   *     signatureMapNative = loadSignaturesNative();
-   *   } else {
-   *     methodMapJava = loadMethodsJava();
-   *     methodMapNative = null;
-   *     signatureMapJava = loadSignaturesJava();
-   *     signatureMapNative = null;
-   *   }
-   * }
-   * </pre>
-   */
   private void writeStaticInitializer() {
     srcWriter.println("static {");
     srcWriter.indent();