Fix for issue #972; removes dependency from RPC server code into gwt-dev. Also removes an unneeded param from TypeInfo.getSourceRepresentation().
Found by: mmendez
Review by: mmendez (postmortem)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@996 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java b/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
index b183cd1..0a3cad7 100644
--- a/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
+++ b/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
@@ -219,7 +219,7 @@
// Just don't know what do to with this.
throw new IllegalArgumentException(msgPrefix + ": Cannot convert to type "
- + TypeInfo.getSourceRepresentation(type, "") + " from "
+ + TypeInfo.getSourceRepresentation(type) + " from "
+ value.getTypeString());
}
diff --git a/dev/core/src/com/google/gwt/dev/util/TypeInfo.java b/dev/core/src/com/google/gwt/dev/util/TypeInfo.java
index 543ea06..30e686fe 100644
--- a/dev/core/src/com/google/gwt/dev/util/TypeInfo.java
+++ b/dev/core/src/com/google/gwt/dev/util/TypeInfo.java
@@ -111,7 +111,7 @@
return after.toString();
}
- public static String getSourceRepresentation(Class type, String optArrayDim) {
+ public static String getSourceRepresentation(Class type) {
// Primitives
//
if (type.equals(Integer.TYPE)) {
@@ -136,7 +136,7 @@
//
if (type.isArray()) {
Class componentType = type.getComponentType();
- return getSourceRepresentation(componentType, optArrayDim) + "[]";
+ return getSourceRepresentation(componentType) + "[]";
}
// Everything else
diff --git a/user/src/com/google/gwt/user/server/rpc/RPC.java b/user/src/com/google/gwt/user/server/rpc/RPC.java
index efa84e5..acb36ff 100644
--- a/user/src/com/google/gwt/user/server/rpc/RPC.java
+++ b/user/src/com/google/gwt/user/server/rpc/RPC.java
@@ -15,7 +15,6 @@
*/
package com.google.gwt.user.server.rpc;
-import com.google.gwt.dev.util.TypeInfo;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.server.rpc.impl.ServerSerializableTypeOracle;
@@ -185,7 +184,7 @@
// The service does not implement the requested interface
throw new SecurityException("Blocked attempt to access interface '"
+ serviceIntfName + "', which is not implemented by '"
- + TypeInfo.getSourceRepresentation(type, "")
+ + printTypeName(type)
+ "'; this is either misconfiguration or a hack attempt");
}
}
@@ -197,7 +196,7 @@
// The requested interface is not a RemoteService interface
throw new SecurityException(
"Blocked attempt to access interface '"
- + TypeInfo.getSourceRepresentation(serviceIntf, "")
+ + printTypeName(serviceIntf)
+ "', which doesn't extend RemoteService; this is either misconfiguration or a hack attempt");
}
} catch (ClassNotFoundException e) {
@@ -304,7 +303,7 @@
if (actualReturnType == null
|| !methodReturnType.isAssignableFrom(actualReturnType)) {
throw new IllegalArgumentException("Type '"
- + TypeInfo.getSourceRepresentation(object.getClass(), "")
+ + printTypeName(object.getClass())
+ "' does not match the return type in the method's signature: '"
+ getSourceRepresentation(serviceMethod) + "'");
}
@@ -427,7 +426,7 @@
if (target != null) {
sb.append(" on target '");
- sb.append(TypeInfo.getSourceRepresentation(target.getClass(), ""));
+ sb.append(printTypeName(target.getClass()));
sb.append("'");
}
@@ -445,7 +444,7 @@
if (target != null) {
sb.append(" on target '");
- sb.append(TypeInfo.getSourceRepresentation(target.getClass(), ""));
+ sb.append(printTypeName(target.getClass()));
sb.append("'");
}
@@ -469,12 +468,12 @@
if (i > 0) {
sb.append(", ");
}
- sb.append(TypeInfo.getSourceRepresentation(parameterTypes[i], ""));
+ sb.append(printTypeName(parameterTypes[i]));
}
sb.append(")'");
sb.append(" in interface '");
- sb.append(TypeInfo.getSourceRepresentation(serviceIntf, ""));
+ sb.append(printTypeName(serviceIntf));
sb.append("'");
return sb.toString();
@@ -637,6 +636,44 @@
}
/**
+ * Straight copy from
+ * {@link com.google.gwt.dev.util.TypeInfo#getSourceRepresentation(Class)} to
+ * avoid runtime dependency on gwt-dev.
+ */
+ private static String printTypeName(Class type) {
+ // Primitives
+ //
+ if (type.equals(Integer.TYPE)) {
+ return "int";
+ } else if (type.equals(Long.TYPE)) {
+ return "long";
+ } else if (type.equals(Short.TYPE)) {
+ return "short";
+ } else if (type.equals(Byte.TYPE)) {
+ return "byte";
+ } else if (type.equals(Character.TYPE)) {
+ return "char";
+ } else if (type.equals(Boolean.TYPE)) {
+ return "boolean";
+ } else if (type.equals(Float.TYPE)) {
+ return "float";
+ } else if (type.equals(Double.TYPE)) {
+ return "double";
+ }
+
+ // Arrays
+ //
+ if (type.isArray()) {
+ Class componentType = type.getComponentType();
+ return printTypeName(componentType) + "[]";
+ }
+
+ // Everything else
+ //
+ return type.getName().replace('$', '.');
+ }
+
+ /**
* Static classes have no constructability.
*/
private RPC() {