Revision: 9337
Author: gwt.mirror...@gmail.com
Date: Thu Dec  2 04:45:53 2010
Log: Factors out TypeOracleMediator.computeBinaryClassName() to be a method on JType. This function doesn't really have anything to do with the type oracle mediator.
Moving it gets rid of most code references to the TypeOracleMediator class.

This change is in preparation for some refactoring TypeOracleMediator and friends.

Review at http://gwt-code-reviews.appspot.com/1144801

http://code.google.com/p/google-web-toolkit/source/detail?r=9337

Modified:
 /trunk/dev/core/src/com/google/gwt/core/ext/typeinfo/JType.java
 /trunk/dev/core/src/com/google/gwt/dev/javac/TypeOracleMediator.java
 /trunk/dev/core/src/com/google/gwt/dev/javac/asm/ResolveTypeSignature.java
 /trunk/user/src/com/google/gwt/rpc/rebind/RpcProxyCreator.java
 /trunk/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java
 /trunk/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
 /trunk/user/src/com/google/gwt/user/rebind/rpc/SerializationUtils.java
 /trunk/user/src/com/google/gwt/user/rebind/rpc/TypeSerializerCreator.java

=======================================
--- /trunk/dev/core/src/com/google/gwt/core/ext/typeinfo/JType.java Tue Nov 16 11:41:39 2010 +++ /trunk/dev/core/src/com/google/gwt/core/ext/typeinfo/JType.java Thu Dec 2 04:45:53 2010
@@ -44,10 +44,15 @@
   }

   /**
-   * TODO(scottb): remove if we can resolve param names differently.
+   * A binary type name as specified by the
+ * <a href="http://java.sun.com/docs/books/jls/second_edition/html/binaryComp.doc.html";>
+   * Java Language Spec, Edition 2</a>.
    */
   public abstract String getQualifiedBinaryName();

+  /**
+   * A type name as it would be specified in Java source.
+   */
   public abstract String getQualifiedSourceName();

   public abstract String getSimpleSourceName();
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/TypeOracleMediator.java Tue Nov 16 11:41:39 2010 +++ /trunk/dev/core/src/com/google/gwt/dev/javac/TypeOracleMediator.java Thu Dec 2 04:45:53 2010
@@ -90,47 +90,6 @@
    * Turn on to trace class processing.
    */
   private static final boolean TRACE_CLASSES = false;
-
-  /**
-   * Returns the binary name of a type. This is the same name that would be
-   * returned by {...@link Class#getName()} for this type.
-   *
-   * @param type TypeOracle type to get the name for
-   * @return binary name for a type
-   */
-  public static String computeBinaryClassName(JType type) {
-    JPrimitiveType primitiveType = type.isPrimitive();
-    if (primitiveType != null) {
-      return primitiveType.getJNISignature();
-    }
-
-    JArrayType arrayType = type.isArray();
-    if (arrayType != null) {
-      JType component = arrayType.getComponentType();
-      if (component.isClassOrInterface() != null) {
-        return "[L" + computeBinaryClassName(arrayType.getComponentType())
-            + ";";
-      } else {
-        return "[" + computeBinaryClassName(arrayType.getComponentType());
-      }
-    }
-
-    JParameterizedType parameterizedType = type.isParameterized();
-    if (parameterizedType != null) {
-      return computeBinaryClassName(parameterizedType.getBaseType());
-    }
-
-    JClassType classType = type.isClassOrInterface();
-    assert (classType != null);
-
-    JClassType enclosingType = classType.getEnclosingType();
-    if (enclosingType != null) {
-      return computeBinaryClassName(enclosingType) + "$"
-          + classType.getSimpleSourceName();
-    }
-
-    return classType.getQualifiedSourceName();
-  }

   private static JTypeParameter[] collectTypeParams(String signature) {
     if (signature != null) {
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/asm/ResolveTypeSignature.java Tue Nov 16 11:41:39 2010 +++ /trunk/dev/core/src/com/google/gwt/dev/javac/asm/ResolveTypeSignature.java Thu Dec 2 04:45:53 2010
@@ -24,8 +24,8 @@
 import com.google.gwt.core.ext.typeinfo.JType;
 import com.google.gwt.core.ext.typeinfo.JTypeParameter;
 import com.google.gwt.core.ext.typeinfo.JWildcardType;
-import com.google.gwt.core.ext.typeinfo.NotFoundException;
 import com.google.gwt.core.ext.typeinfo.JWildcardType.BoundType;
+import com.google.gwt.core.ext.typeinfo.NotFoundException;
 import com.google.gwt.dev.asm.signature.SignatureVisitor;
 import com.google.gwt.dev.javac.Resolver;
 import com.google.gwt.dev.javac.TypeParameterLookup;
=======================================
--- /trunk/user/src/com/google/gwt/rpc/rebind/RpcProxyCreator.java Wed Sep 1 13:19:51 2010 +++ /trunk/user/src/com/google/gwt/rpc/rebind/RpcProxyCreator.java Thu Dec 2 04:45:53 2010
@@ -30,7 +30,6 @@
 import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
 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.dev.util.collect.Lists;
 import com.google.gwt.rpc.client.impl.CommandToStringWriter;
 import com.google.gwt.rpc.client.impl.RpcServiceProxy;
@@ -71,7 +70,7 @@
     if (paramType.isClass() != null) {
       return "GWT.isScript() ? Impl.getNameOf(\"@"
           + paramType.getQualifiedSourceName() + "\") : \""
-          + TypeOracleMediator.computeBinaryClassName(paramType) + "\"";
+          + SerializationUtils.getRpcTypeName(paramType) + "\"";
     } else {
       /*
* Consider the case of service methods that have interface parameters;
@@ -79,7 +78,7 @@
* encode these type names in a way that can always be distinguished from
        * obfuscated type names.
        */
-      return "\" " + TypeOracleMediator.computeBinaryClassName(paramType)
+      return "\" " + SerializationUtils.getRpcTypeName(paramType)
           + "\"";
     }
   }
@@ -292,7 +291,7 @@
         names = Lists.add(names, serializableFields[i].getName());
       }

- data.setFields(TypeOracleMediator.computeBinaryClassName(type), names);
+      data.setFields(SerializationUtils.getRpcTypeName(type), names);
     }

     ctx.commitArtifact(logger, data);
=======================================
--- /trunk/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java Mon Oct 25 05:01:41 2010 +++ /trunk/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java Thu Dec 2 04:45:53 2010
@@ -29,7 +29,6 @@
 import com.google.gwt.core.ext.typeinfo.JType;
 import com.google.gwt.core.ext.typeinfo.JTypeParameter;
 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;
@@ -603,7 +602,7 @@
       sourceWriter.println("}");
       sourceWriter.println();
     } else {
- String jsniTypeRef = TypeOracleMediator.computeBinaryClassName(serializableClass); + String jsniTypeRef = SerializationUtils.getRpcTypeName(serializableClass); sourceWriter.println("public static native Class<?> concreteType() /*-{");
       sourceWriter.indentln("return @" + jsniTypeRef + "::class;");
       sourceWriter.println("}-*/;");
@@ -681,7 +680,7 @@
     sourceWriter.indent();

     sourceWriter.print("return instance.@");
- sourceWriter.print(TypeOracleMediator.computeBinaryClassName(serializableClass)); + sourceWriter.print(SerializationUtils.getRpcTypeName(serializableClass));
     sourceWriter.print("::");
     sourceWriter.print(fieldName);
     sourceWriter.println(";");
@@ -712,7 +711,7 @@
     sourceWriter.indent();

     sourceWriter.print("instance.@");
- sourceWriter.print(TypeOracleMediator.computeBinaryClassName(serializableClass)); + sourceWriter.print(SerializationUtils.getRpcTypeName(serializableClass));
     sourceWriter.print("::");
     sourceWriter.print(fieldName);
     sourceWriter.println(" = value;");
=======================================
--- /trunk/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java Tue Nov 23 13:47:33 2010 +++ /trunk/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java Thu Dec 2 04:45:53 2010
@@ -36,7 +36,6 @@
 import com.google.gwt.core.ext.typeinfo.NotFoundException;
 import com.google.gwt.core.ext.typeinfo.TypeOracle;
 import com.google.gwt.dev.generator.NameFactory;
-import com.google.gwt.dev.javac.TypeOracleMediator;
 import com.google.gwt.dev.util.Util;
 import com.google.gwt.http.client.Request;
 import com.google.gwt.http.client.RequestBuilder;
@@ -338,7 +337,7 @@

     String remoteServiceInterfaceName = elideTypeNames
         ? TypeNameObfuscator.SERVICE_INTERFACE_ID
-        : TypeOracleMediator.computeBinaryClassName(serviceIntf);
+        : SerializationUtils.getRpcTypeName(serviceIntf);
     generateProxyFields(srcWriter, typesSentFromBrowser,
         serializationPolicyStrongName, remoteServiceInterfaceName);

@@ -385,7 +384,7 @@
     if (typeStrings.containsKey(paramType)) {
       typeName = typeStrings.get(paramType);
     } else {
-      typeName = TypeOracleMediator.computeBinaryClassName(paramType);
+      typeName = SerializationUtils.getRpcTypeName(paramType);
     }
     return typeName == null ? null : ('"' + typeName + '"');
   }
@@ -738,7 +737,7 @@

       for (int i = 0; i < serializableTypes.length; ++i) {
         JType type = serializableTypes[i];
- String binaryTypeName = TypeOracleMediator.computeBinaryClassName(type);
+        String binaryTypeName = SerializationUtils.getRpcTypeName(type);
         pw.print(binaryTypeName);
         pw.print(", "
             + Boolean.toString(deserializationSto.isSerializable(type)));
=======================================
--- /trunk/user/src/com/google/gwt/user/rebind/rpc/SerializationUtils.java Fri Sep 24 06:17:22 2010 +++ /trunk/user/src/com/google/gwt/user/rebind/rpc/SerializationUtils.java Thu Dec 2 04:45:53 2010
@@ -20,9 +20,9 @@
 import com.google.gwt.core.ext.typeinfo.JClassType;
 import com.google.gwt.core.ext.typeinfo.JField;
 import com.google.gwt.core.ext.typeinfo.JParameterizedType;
+import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
 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.dev.util.Util;

 import java.io.UnsupportedEncodingException;
@@ -68,6 +68,47 @@
TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("junit.framework.AssertionFailedError");
   }

+  /**
+   * Returns the binary name of a type. This is the same name that would be
+   * returned by {...@link Class#getName()} for this type.
+   *
+   * @param type TypeOracle type to get the name for
+   * @return binary name for a type
+   */
+  public static String getRpcTypeName(JType type) {
+    JPrimitiveType primitiveType = type.isPrimitive();
+    if (primitiveType != null) {
+      return primitiveType.getJNISignature();
+    }
+
+    JArrayType arrayType = type.isArray();
+    if (arrayType != null) {
+      JType component = arrayType.getComponentType();
+      if (component.isClassOrInterface() != null) {
+        return "[L" + getRpcTypeName(arrayType.getComponentType())
+            + ";";
+      } else {
+        return "[" + getRpcTypeName(arrayType.getComponentType());
+      }
+    }
+
+    JParameterizedType parameterizedType = type.isParameterized();
+    if (parameterizedType != null) {
+      return getRpcTypeName(parameterizedType.getBaseType());
+    }
+
+    JClassType classType = type.isClassOrInterface();
+    assert (classType != null);
+
+    JClassType enclosingType = classType.getEnclosingType();
+    if (enclosingType != null) {
+      return getRpcTypeName(enclosingType) + "$"
+          + classType.getSimpleSourceName();
+    }
+
+    return classType.getQualifiedSourceName();
+  }
+
   /**
* Returns the set of fields that are serializable for a given class type.
    * This method does not consider any superclass fields.
@@ -218,7 +259,7 @@
       return;
     }

- String serializedTypeName = TypeOracleMediator.computeBinaryClassName(type);
+    String serializedTypeName = getRpcTypeName(type);
     crc.update(serializedTypeName.getBytes(Util.DEFAULT_ENCODING));

     if (excludeImplementationFromSerializationSignature(type)) {
@@ -240,7 +281,7 @@
         assert (field != null);

         crc.update(field.getName().getBytes(Util.DEFAULT_ENCODING));
- crc.update(TypeOracleMediator.computeBinaryClassName(field.getType()).getBytes(
+        crc.update(getRpcTypeName(field.getType()).getBytes(
             Util.DEFAULT_ENCODING));
       }

@@ -250,5 +291,4 @@
       }
     }
   }
-
-}
+}
=======================================
--- /trunk/user/src/com/google/gwt/user/rebind/rpc/TypeSerializerCreator.java Mon Oct 25 05:01:41 2010 +++ /trunk/user/src/com/google/gwt/user/rebind/rpc/TypeSerializerCreator.java Thu Dec 2 04:45:53 2010
@@ -28,7 +28,6 @@
 import com.google.gwt.core.ext.typeinfo.JParameterizedType;
 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.SerializationStreamReader;
 import com.google.gwt.user.client.rpc.SerializationStreamWriter;
 import com.google.gwt.user.client.rpc.impl.SerializerBase;
@@ -287,7 +286,7 @@
    * @return
    */
   private String getTypeString(JType type) {
- String typeString = TypeOracleMediator.computeBinaryClassName(type) + "/"
+    String typeString = SerializationUtils.getRpcTypeName(type) + "/"
         + SerializationUtils.getSerializationSignature(typeOracle, type);
     return typeString;
   }
@@ -522,7 +521,7 @@
       }

       String jsniTypeRef;
- jsniTypeRef = TypeOracleMediator.computeBinaryClassName(type.getLeafType());
+      jsniTypeRef = SerializationUtils.getRpcTypeName(type.getLeafType());
       while (type.isArray() != null) {
         jsniTypeRef += "[]";
         type = type.isArray().getComponentType();

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

Reply via email to