Reviewers: amitmanjhi, Message: Request review.
Description: This patch fixes three small issues: 1) Canonicalization of inner array type names 2) Ensuring that primitive return types for service methods cause their boxed counterparts to be rescued since return types are boxed over the wire. 3) Re-use an existing local variable. Please review this at http://gwt-code-reviews.appspot.com/54801 Affected files: M user/src/com/google/gwt/rpc/rebind/RpcProxyCreator.java M user/src/com/google/gwt/rpc/server/WebModeClientOracle.java M user/src/com/google/gwt/rpc/server/WebModePayloadSink.java Index: user/src/com/google/gwt/rpc/rebind/RpcProxyCreator.java diff --git a/user/src/com/google/gwt/rpc/rebind/RpcProxyCreator.java b/user/src/com/google/gwt/rpc/rebind/RpcProxyCreator.java index 7c01bb7fe68748e8166579aa2d67240304139d9e..2467976d43069fbb8e90ce1064b95003d46720a6 100644 --- a/user/src/com/google/gwt/rpc/rebind/RpcProxyCreator.java +++ b/user/src/com/google/gwt/rpc/rebind/RpcProxyCreator.java @@ -302,12 +302,20 @@ public class RpcProxyCreator extends ProxyCreator { serializationSto.getSerializableTypes()); Collections.addAll(serializableTypes, deserializationSto.getSerializableTypes()); + for (JMethod m : serviceIntf.getOverridableMethods()) { + // Pick up any primitive return types, which get sent boxed + assert serializableTypes.contains(m.getReturnType()) + || m.getReturnType().isPrimitive() != null : "Missing non-primitive return type " + + m.getReturnType().getQualifiedSourceName(); + serializableTypes.add(m.getReturnType()); + } StringBuilder sb = new StringBuilder("@ArtificialRescue({"); for (JType serializableType : serializableTypes) { JArrayType serializableArray = serializableType.isArray(); JClassType serializableClass = serializableType.isClass(); + JPrimitiveType serializablePrimitive = serializableType.isPrimitive(); if (serializableArray != null) { sb.append("\...@rescue(className = \""); if (serializableArray.getLeafType() instanceof JPrimitiveType) { @@ -319,8 +327,15 @@ public class RpcProxyCreator extends ProxyCreator { sb.append(serializableArray.getQualifiedSourceName()); } sb.append("\",\n instantiable = true),"); + } else if (serializableClass != null) { writeSingleRescue(typeOracle, deserializationSto, sb, serializableClass); + + } else if (serializablePrimitive != null) { + JClassType boxedClass = typeOracle.findType(serializablePrimitive.getQualifiedBoxedSourceName()); + assert boxedClass != null : "No boxed version of " + + serializablePrimitive.getQualifiedSourceName(); + writeSingleRescue(typeOracle, deserializationSto, sb, boxedClass); } } sb.append("})"); Index: user/src/com/google/gwt/rpc/server/WebModeClientOracle.java diff --git a/user/src/com/google/gwt/rpc/server/WebModeClientOracle.java b/user/src/com/google/gwt/rpc/server/WebModeClientOracle.java index 42090b8ec587e666754f2a21874d3e11b6daade0..97e626259a9ec94f591451bfe83f1648650c2d9f 100644 --- a/user/src/com/google/gwt/rpc/server/WebModeClientOracle.java +++ b/user/src/com/google/gwt/rpc/server/WebModeClientOracle.java @@ -381,9 +381,15 @@ public final class WebModeClientOracle extends ClientOracle implements leafType = leafType.getComponentType(); } while (leafType.isArray()); - if (leafType.getPackage() == null) { + Class<?> enclosing = leafType.getEnclosingClass(); + if (enclosing != null) { + // com.foo.Enclosing$Name[] + return canonicalName(enclosing) + "$" + clazz.getSimpleName(); + } else if (leafType.getPackage() == null) { + // Name0[ return clazz.getSimpleName(); } else { + // com.foo.Name[] return leafType.getPackage().getName() + "." + clazz.getSimpleName(); } } else { Index: user/src/com/google/gwt/rpc/server/WebModePayloadSink.java diff --git a/user/src/com/google/gwt/rpc/server/WebModePayloadSink.java b/user/src/com/google/gwt/rpc/server/WebModePayloadSink.java index 924a55b8c406cb781c6635e883b8e7aec693fea9..3edbec89ddd9072ee270df6ead03afb150078e0a 100644 --- a/user/src/com/google/gwt/rpc/server/WebModePayloadSink.java +++ b/user/src/com/google/gwt/rpc/server/WebModePayloadSink.java @@ -555,8 +555,7 @@ public class WebModePayloadSink extends CommandSink { * Set the typeIds and queryIds to exact values, or fall back to acting * like a plain Object[] array. */ - int typeId = clientOracle.getTypeId(Array.newInstance( - x.getComponentType(), 0).getClass()); + int typeId = clientOracle.getTypeId(targetClass); if (typeId == 0) { typeId = clientOracle.getTypeId(Object[].class); } --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---