diff --git a/src/main/java/com/threerings/presents/client/InvocationDecoder.java b/src/main/java/com/threerings/presents/client/InvocationDecoder.java index 12d3e12dd..a19b291ac 100644 --- a/src/main/java/com/threerings/presents/client/InvocationDecoder.java +++ b/src/main/java/com/threerings/presents/client/InvocationDecoder.java @@ -45,4 +45,13 @@ public abstract class InvocationDecoder log.warning("Requested to dispatch unknown method", "receiver", receiver, "methodId", methodId, "args", args); } + + /** + * Performs type casts in a way that works for parameterized types as well as simple types. + */ + @SuppressWarnings("unchecked") + protected T cast (Object value) + { + return (T)value; + } } diff --git a/src/main/java/com/threerings/presents/server/InvocationDispatcher.java b/src/main/java/com/threerings/presents/server/InvocationDispatcher.java index 1c580fccc..02aa1d203 100644 --- a/src/main/java/com/threerings/presents/server/InvocationDispatcher.java +++ b/src/main/java/com/threerings/presents/server/InvocationDispatcher.java @@ -49,4 +49,13 @@ public abstract class InvocationDispatcher log.warning("Requested to dispatch unknown method", "provider", provider, "sourceOid", source.getOid(), "methodId", methodId, "args", args); } + + /** + * Performs type casts in a way that works for parameterized types as well as simple types. + */ + @SuppressWarnings("unchecked") + protected T cast (Object value) + { + return (T)value; + } } diff --git a/src/main/java/com/threerings/presents/tools/GenUtil.java b/src/main/java/com/threerings/presents/tools/GenUtil.java index 56f1bd3ce..7dca518d8 100644 --- a/src/main/java/com/threerings/presents/tools/GenUtil.java +++ b/src/main/java/com/threerings/presents/tools/GenUtil.java @@ -133,8 +133,10 @@ public class GenUtil extends com.samskivert.util.GenUtil return "((Double)" + name + ").doubleValue()"; } else if (Object.class.equals(type)) { return name; // no need to cast object - } else { + } else if (type instanceof Class) { return "(" + simpleName(type) + ")" + name; + } else { + return "this.<" + simpleName(type) + ">cast(" + name + ")"; } }