From 1c598a1aebc7ec27c0d4d01e033dc938c9886298 Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Sun, 9 Mar 2008 23:38:26 +0000 Subject: + * Fix returning DBusSerializables (Spotted by Johannes Felten + ) --- org/freedesktop/dbus/Marshalling.java | 5 +++++ org/freedesktop/dbus/RemoteInvocationHandler.java | 2 ++ org/freedesktop/dbus/test/test.java | 7 ++++--- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'org') diff --git a/org/freedesktop/dbus/Marshalling.java b/org/freedesktop/dbus/Marshalling.java index 1d338cd..5028860 100644 --- a/org/freedesktop/dbus/Marshalling.java +++ b/org/freedesktop/dbus/Marshalling.java @@ -561,6 +561,11 @@ public class Marshalling if (Debug.debug) Debug.print(Debug.VERBOSE, "Deserializing from "+Arrays.deepToString(parameters)+" to "+Arrays.deepToString(types)); if (null == parameters) return null; + if (types.length == 1 && types[0] instanceof ParameterizedType + && Tuple.class.isAssignableFrom((Class) ((ParameterizedType) types[0]).getRawType())) { + types = ((ParameterizedType) types[0]).getActualTypeArguments(); + } + for (int i = 0; i < parameters.length; i++) { // CHECK IF ARRAYS HAVE THE SAME LENGTH <-- has to happen after expanding parameters if (i >= types.length) { diff --git a/org/freedesktop/dbus/RemoteInvocationHandler.java b/org/freedesktop/dbus/RemoteInvocationHandler.java index 7308129..e1a262f 100644 --- a/org/freedesktop/dbus/RemoteInvocationHandler.java +++ b/org/freedesktop/dbus/RemoteInvocationHandler.java @@ -19,6 +19,7 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.text.MessageFormat; +import java.util.Arrays; import org.freedesktop.DBus; import org.freedesktop.dbus.exceptions.DBusException; @@ -41,6 +42,7 @@ class RemoteInvocationHandler implements InvocationHandler else throw new DBusExecutionException(_("Wrong return type (got void, expected a value)")); } else { try { + if (Debug.debug) Debug.print(Debug.VERBOSE, "Converting return parameters from "+Arrays.deepToString(rp)+" to type "+m.getGenericReturnType()); rp = Marshalling.deSerializeParameters(rp, new Type[] { m.getGenericReturnType() }, conn); } diff --git a/org/freedesktop/dbus/test/test.java b/org/freedesktop/dbus/test/test.java index 08263c0..dae3e27 100644 --- a/org/freedesktop/dbus/test/test.java +++ b/org/freedesktop/dbus/test/test.java @@ -685,12 +685,13 @@ public class test v.add(3); TestSerializable s = new TestSerializable(1, "woo", v); s = tri2.testSerializable((byte) 12, s, 13); + System.out.print("returned: "+s); if (s.getInt() != 1 || ! s.getString().equals("woo") || s.getVector().size() != 3 || - s.getVector().get(1) != 1 || - s.getVector().get(2) != 2 || - s.getVector().get(3) != 3) + s.getVector().get(0) != 1 || + s.getVector().get(1) != 2 || + s.getVector().get(2) != 3) fail("Didn't get back the same TestSerializable"); System.out.println("done"); -- cgit v1.2.3