summaryrefslogtreecommitdiff
path: root/org
diff options
context:
space:
mode:
authorMatthew Johnson <mjj29@hecate.matthew.ath.cx>2008-03-09 23:38:26 +0000
committerMatthew Johnson <mjj29@hecate.matthew.ath.cx>2008-03-09 23:38:26 +0000
commit1c598a1aebc7ec27c0d4d01e033dc938c9886298 (patch)
tree9409f3c291682f0f0a7d2e4ed146c89bc65251c5 /org
parent0d90d4114e8bc214c001fb9c244b85941f4214bd (diff)
+ * Fix returning DBusSerializables (Spotted by Johannes Felten
+ <johannesfelten -at- googlemail -dot- com>)
Diffstat (limited to 'org')
-rw-r--r--org/freedesktop/dbus/Marshalling.java5
-rw-r--r--org/freedesktop/dbus/RemoteInvocationHandler.java2
-rw-r--r--org/freedesktop/dbus/test/test.java7
3 files changed, 11 insertions, 3 deletions
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<String> s = new TestSerializable<String>(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");