diff options
Diffstat (limited to 'org')
-rw-r--r-- | org/freedesktop/dbus/RemoteInvocationHandler.java | 25 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/TestRemoteInterface2.java | 2 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/test.java | 14 |
3 files changed, 23 insertions, 18 deletions
diff --git a/org/freedesktop/dbus/RemoteInvocationHandler.java b/org/freedesktop/dbus/RemoteInvocationHandler.java index 00e57be..7308129 100644 --- a/org/freedesktop/dbus/RemoteInvocationHandler.java +++ b/org/freedesktop/dbus/RemoteInvocationHandler.java @@ -39,6 +39,15 @@ class RemoteInvocationHandler implements InvocationHandler if (null == rp) { if(null == c || Void.TYPE.equals(c)) return null; else throw new DBusExecutionException(_("Wrong return type (got void, expected a value)")); + } else { + try { + rp = Marshalling.deSerializeParameters(rp, + new Type[] { m.getGenericReturnType() }, conn); + } + catch (Exception e) { + if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e); + throw new DBusExecutionException(MessageFormat.format(_("Wrong return type (failed to de-serialize correct types: {0} )"), new Object[] { e.getMessage() })); + } } switch (rp.length) { @@ -47,27 +56,13 @@ class RemoteInvocationHandler implements InvocationHandler return null; else throw new DBusExecutionException(_("Wrong return type (got void, expected a value)")); case 1: - try { - rp = Marshalling.deSerializeParameters(rp, - new Type[] { m.getGenericReturnType() }, conn); - } - catch (Exception e) { - if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e); - throw new DBusExecutionException(MessageFormat.format(_("Wrong return type (failed to de-serialize correct types: {0} )"), new Object[] { e.getMessage() })); - } - return rp[0]; default: // check we are meant to return multiple values if (!Tuple.class.isAssignableFrom(c)) throw new DBusExecutionException(_("Wrong return type (not expecting Tuple)")); - try { - rp = Marshalling.deSerializeParameters(rp, ((ParameterizedType) m.getGenericReturnType()).getActualTypeArguments(), conn); - } catch (Exception e) { - if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e); - throw new DBusExecutionException(MessageFormat.format(_("Wrong return type (failed to de-serialize correct types: {0})"), new Object[] {e.getMessage()})); - } + Constructor<? extends Object> cons = c.getConstructors()[0]; try { return cons.newInstance(rp); diff --git a/org/freedesktop/dbus/test/TestRemoteInterface2.java b/org/freedesktop/dbus/test/TestRemoteInterface2.java index fb22065..1867ea3 100644 --- a/org/freedesktop/dbus/test/TestRemoteInterface2.java +++ b/org/freedesktop/dbus/test/TestRemoteInterface2.java @@ -34,7 +34,7 @@ public interface TestRemoteInterface2 extends DBusInterface @DBusMemberName("checkbool") public boolean check(); @Description("Test Serializable Object") - public void testSerializable(byte b, TestSerializable<String> s, int i); + public TestSerializable<String> testSerializable(byte b, TestSerializable<String> s, int i); @Description("Call another method on itself from within a call") public String recursionTest(); @Description("Parameter-overloaded method (string)") diff --git a/org/freedesktop/dbus/test/test.java b/org/freedesktop/dbus/test/test.java index fb3f1b7..08263c0 100644 --- a/org/freedesktop/dbus/test/test.java +++ b/org/freedesktop/dbus/test/test.java @@ -217,7 +217,7 @@ class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignal { throw new TestException("test"); } - public void testSerializable(byte b, TestSerializable<String> s, int i) + public TestSerializable<String> testSerializable(byte b, TestSerializable<String> s, int i) { System.out.println("Recieving TestSerializable: "+s); if ( b != 12 @@ -229,6 +229,7 @@ class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignal || !(s.getVector().get(1) == 2) || !(s.getVector().get(2) == 3) ) test.fail("Error in recieving custom synchronisation"); + return s; } public String recursionTest() { @@ -420,6 +421,8 @@ public class test System.out.println("Creating Connection"); serverconn = DBusConnection.getConnection(DBusConnection.SESSION); clientconn = DBusConnection.getConnection(DBusConnection.SESSION); + serverconn.setWeakReferences(true); + clientconn.setWeakReferences(true); System.out.println("Registering Name"); serverconn.requestBusName("foo.bar.Test"); @@ -681,7 +684,14 @@ public class test v.add(2); v.add(3); TestSerializable<String> s = new TestSerializable<String>(1, "woo", v); - tri2.testSerializable((byte) 12, s, 13); + s = tri2.testSerializable((byte) 12, s, 13); + 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) + fail("Didn't get back the same TestSerializable"); System.out.println("done"); |