diff options
24 files changed, 89 insertions, 62 deletions
@@ -1,7 +1,6 @@ ** check that the blocking is correct on DBusAsyncReply and add an explicit timeout value * only hold weak refs to user objects and reply correctly when they have gone * Javadoc - * don't respond to Introspect/Ping except on the right interface Serkan Kaba <serkan_kaba -at- yahoo -dot- com> * document that we handle Introspect for you * add header checks to daemon * add TERM/etc handler to DBusDaemon @@ -1,8 +1,11 @@ Version 2.4: * Add DBusMemberName to force method names or signal names to something - other than the Java name (suggested byaViktar Vauchkevich <vctr -at- + other than the Java name (suggested byaViktar Vauchkevich <vctr -at- yandex -dot- ru>) + * Don't respond to Introspect/Ping except on the right interface + (pointed out by Serkan Kaba <serkan_kaba -at- yahoo -dot- com>) + Version 2.3.2: diff --git a/org/freedesktop/dbus/AbstractConnection.java b/org/freedesktop/dbus/AbstractConnection.java index cae181a..a66771b 100644 --- a/org/freedesktop/dbus/AbstractConnection.java +++ b/org/freedesktop/dbus/AbstractConnection.java @@ -593,18 +593,21 @@ public abstract class AbstractConnection ExportedObject eo = null; Method meth = null; - Object o; + Object o = null; - synchronized (exportedObjects) { - eo = exportedObjects.get(null); - } - if (null != eo) { - meth = eo.methods.get(new MethodTuple(m.getName(), m.getSig())); + if (null == m.getInterface() || + m.getInterface().equals("org.freedesktop.DBus.Peer") || + m.getInterface().equals("org.freedesktop.DBus.Introspectable")) { + synchronized (exportedObjects) { + eo = exportedObjects.get(null); + } + if (null != eo) { + meth = eo.methods.get(new MethodTuple(m.getName(), m.getSig())); + } + if (null != meth) + o = new _globalhandler(m.getPath()); } - if (null != meth) - o = new _globalhandler(m.getPath()); - - else { + if (null == o) { // now check for specific exported functions synchronized (exportedObjects) { diff --git a/org/freedesktop/dbus/DBusConnection.java b/org/freedesktop/dbus/DBusConnection.java index 4bac4df..fcd2088 100644 --- a/org/freedesktop/dbus/DBusConnection.java +++ b/org/freedesktop/dbus/DBusConnection.java @@ -168,7 +168,7 @@ public class DBusConnection extends AbstractConnection addSigHandlerWithoutMatch(org.freedesktop.DBus.NameAcquired.class, h); // register ourselves - _dbus = (DBus) getRemoteObject("org.freedesktop.DBus", "/org/freedesktop/DBus", DBus.class); + _dbus = getRemoteObject("org.freedesktop.DBus", "/org/freedesktop/DBus", DBus.class); try { busnames.add(_dbus.Hello()); } catch (DBusExecutionException DBEe) { @@ -180,7 +180,7 @@ public class DBusConnection extends AbstractConnection DBusInterface dynamicProxy(String source, String path) throws DBusException { try { - DBus.Introspectable intro = (DBus.Introspectable) getRemoteObject(source, path, DBus.Introspectable.class); + DBus.Introspectable intro = getRemoteObject(source, path, DBus.Introspectable.class); String data = intro.Introspect(); String[] tags = data.split("[<>]"); Vector<String> ifaces = new Vector<String>(); @@ -209,8 +209,10 @@ public class DBusConnection extends AbstractConnection if (ifcs.size() == 0) throw new DBusException("Could not find an interface to cast to"); RemoteObject ro = new RemoteObject(source, path, null, false); - DBusInterface newi = (DBusInterface) Proxy.newProxyInstance(ifcs.get(0).getClassLoader(), - (Class[]) ifcs.toArray(new Class[0]), new RemoteInvocationHandler(this, ro)); + DBusInterface newi = (DBusInterface) + Proxy.newProxyInstance(ifcs.get(0).getClassLoader(), + ifcs.toArray(new Class[0]), + new RemoteInvocationHandler(this, ro)); importedObjects.put(newi, ro); return newi; } catch (Exception e) { diff --git a/org/freedesktop/dbus/DBusMatchRule.java b/org/freedesktop/dbus/DBusMatchRule.java index 3a5da1a..3bd1d77 100644 --- a/org/freedesktop/dbus/DBusMatchRule.java +++ b/org/freedesktop/dbus/DBusMatchRule.java @@ -60,6 +60,7 @@ public class DBusMatchRule this.source = source; this.object = object; } + @SuppressWarnings("unchecked") public DBusMatchRule(Class c) throws DBusException { if (DBusInterface.class.isAssignableFrom(c)) { diff --git a/org/freedesktop/dbus/DBusSignal.java b/org/freedesktop/dbus/DBusSignal.java index 2e9dcee..250b094 100644 --- a/org/freedesktop/dbus/DBusSignal.java +++ b/org/freedesktop/dbus/DBusSignal.java @@ -160,6 +160,7 @@ public class DBusSignal extends Message * @param args The parameters of the signal. * @throws DBusException This is thrown if the subclass is incorrectly defined. */ + @SuppressWarnings("unchecked") protected DBusSignal(String objectpath, Object... args) throws DBusException { super(Message.Endian.BIG, Message.MessageType.SIGNAL, (byte) 0); diff --git a/org/freedesktop/dbus/DirectConnection.java b/org/freedesktop/dbus/DirectConnection.java index 2753258..3fd2a2b 100644 --- a/org/freedesktop/dbus/DirectConnection.java +++ b/org/freedesktop/dbus/DirectConnection.java @@ -123,8 +123,10 @@ public class DirectConnection extends AbstractConnection if (ifcs.size() == 0) throw new DBusException("Could not find an interface to cast to"); RemoteObject ro = new RemoteObject(null, path, null, false); - DBusInterface newi = (DBusInterface) Proxy.newProxyInstance(ifcs.get(0).getClassLoader(), - (Class[]) ifcs.toArray(new Class[0]), new RemoteInvocationHandler(this, ro)); + DBusInterface newi = (DBusInterface) + Proxy.newProxyInstance(ifcs.get(0).getClassLoader(), + ifcs.toArray(new Class[0]), + new RemoteInvocationHandler(this, ro)); importedObjects.put(newi, ro); return newi; } catch (Exception e) { diff --git a/org/freedesktop/dbus/ExportedObject.java b/org/freedesktop/dbus/ExportedObject.java index 5f7c80a..a60ab79 100644 --- a/org/freedesktop/dbus/ExportedObject.java +++ b/org/freedesktop/dbus/ExportedObject.java @@ -26,6 +26,7 @@ import org.freedesktop.dbus.exceptions.DBusExecutionException; class ExportedObject { + @SuppressWarnings("unchecked") private String getAnnotations(AnnotatedElement c) { String ans = ""; @@ -43,6 +44,7 @@ class ExportedObject } return ans; } + @SuppressWarnings("unchecked") private Map<MethodTuple,Method> getExportedMethods(Class c) throws DBusException { if (DBusInterface.class.equals(c)) return new HashMap<MethodTuple,Method>(); @@ -70,7 +72,7 @@ class ExportedObject String ms = ""; String name; if (meth.isAnnotationPresent(DBusMemberName.class)) - name = ((DBusMemberName) meth.getAnnotation(DBusMemberName.class)).value(); + name = meth.getAnnotation(DBusMemberName.class).value(); else name = meth.getName(); if (name.length() > DBusConnection.MAX_NAME_LENGTH) diff --git a/org/freedesktop/dbus/Marshalling.java b/org/freedesktop/dbus/Marshalling.java index c0f2518..9ba0b44 100644 --- a/org/freedesktop/dbus/Marshalling.java +++ b/org/freedesktop/dbus/Marshalling.java @@ -145,7 +145,7 @@ public class Marshalling for (Type t: ts) for (String s: recursiveGetDBusType(t, false, level+1)) vs.add(s); - return (String[]) vs.toArray(new String[0]); + return vs.toArray(new String[0]); } else throw new DBusException("Exporting non-exportable parameterized type "+c); @@ -515,7 +515,7 @@ public class Marshalling } return parameter; } - static List deSerializeParameters(List parameters, Type type, AbstractConnection conn) throws Exception + static List<Object> deSerializeParameters(List<Object> parameters, Type type, AbstractConnection conn) throws Exception { if (Debug.debug) Debug.print(Debug.VERBOSE, "Deserializing from "+parameters+" to "+type); if (null == parameters) return null; diff --git a/org/freedesktop/dbus/Message.java b/org/freedesktop/dbus/Message.java index 186604f..c4ab12d 100644 --- a/org/freedesktop/dbus/Message.java +++ b/org/freedesktop/dbus/Message.java @@ -465,7 +465,7 @@ public class Message { try { int i = sigofs; - if (Debug.debug) Debug.print((int) Debug.VERBOSE, (Object) bytecounter); + if (Debug.debug) Debug.print(Debug.VERBOSE, (Object) bytecounter); if (Debug.debug) Debug.print(Debug.VERBOSE, "Appending type: "+((char)sigb[i])+" value: "+data); // pad to the alignment of this type. @@ -865,7 +865,7 @@ public class Message case ArgumentType.INT64: rv = new long[length]; for (int j = 0; j < length; j++, ofs[1] += algn) - ((long[]) rv)[j] = (long) demarshallint(buf, ofs[1], algn); + ((long[]) rv)[j] = demarshallint(buf, ofs[1], algn); break; case ArgumentType.BOOLEAN: rv = new boolean[length]; @@ -971,7 +971,7 @@ public class Message break; case ArgumentType.SIGNATURE: length = (buf[ofs[1]++] & 0xFF); - rv = new String(buf, ofs[1], (int)length); + rv = new String(buf, ofs[1], length); ofs[1] += length + 1; break; default: diff --git a/org/freedesktop/dbus/RemoteInvocationHandler.java b/org/freedesktop/dbus/RemoteInvocationHandler.java index 587ec37..106438d 100644 --- a/org/freedesktop/dbus/RemoteInvocationHandler.java +++ b/org/freedesktop/dbus/RemoteInvocationHandler.java @@ -96,7 +96,7 @@ class RemoteInvocationHandler implements InvocationHandler try { String name; if (m.isAnnotationPresent(DBusMemberName.class)) - name = ((DBusMemberName) m.getAnnotation(DBusMemberName.class)).value(); + name = m.getAnnotation(DBusMemberName.class).value(); else name = m.getName(); if (null == ro.iface) diff --git a/org/freedesktop/dbus/Transport.java b/org/freedesktop/dbus/Transport.java index 9c25d5a..37b631d 100644 --- a/org/freedesktop/dbus/Transport.java +++ b/org/freedesktop/dbus/Transport.java @@ -451,6 +451,7 @@ public class Transport * Types is a bitmask of the available auth types. * Returns true if the auth was successful and false if it failed. */ + @SuppressWarnings("unchecked") public boolean auth(int mode, int types, String guid, OutputStream out, InputStream in) throws IOException { String username = System.getProperty("user.name"); diff --git a/org/freedesktop/dbus/UInt16.java b/org/freedesktop/dbus/UInt16.java index 0063bfe..44ddf45 100644 --- a/org/freedesktop/dbus/UInt16.java +++ b/org/freedesktop/dbus/UInt16.java @@ -46,7 +46,7 @@ public class UInt16 extends Number implements Comparable<UInt16> /** The value of this as a float. */ public float floatValue() { return (float) value; } /** The value of this as a int. */ - public int intValue() { return (int) value; } + public int intValue() { return /*(int)*/ value; } /** The value of this as a long. */ public long longValue() { return (long) value; } /** The value of this as a short. */ @@ -58,14 +58,14 @@ public class UInt16 extends Number implements Comparable<UInt16> } public int hashCode() { - return (int) value; + return /*(int)*/ value; } /** Compare two UInt16s. * @return 0 if equal, -ve or +ve if they are different. */ public int compareTo(UInt16 other) { - return (int) (this.value - other.value); + return /*(int)*/ (this.value - other.value); } /** The value of this as a string. */ public String toString() diff --git a/org/freedesktop/dbus/UInt32.java b/org/freedesktop/dbus/UInt32.java index 1b52616..96bbb7a 100644 --- a/org/freedesktop/dbus/UInt32.java +++ b/org/freedesktop/dbus/UInt32.java @@ -48,7 +48,7 @@ public class UInt32 extends Number implements Comparable<UInt32> /** The value of this as a int. */ public int intValue() { return (int) value; } /** The value of this as a long. */ - public long longValue() { return (long) value; } + public long longValue() { return /*(long)*/ value; } /** The value of this as a short. */ public short shortValue(){ return (short) value; } /** Test two UInt32s for equality. */ diff --git a/org/freedesktop/dbus/bin/Caller.java b/org/freedesktop/dbus/bin/Caller.java index 188b3c1..9b7c6f2 100644 --- a/org/freedesktop/dbus/bin/Caller.java +++ b/org/freedesktop/dbus/bin/Caller.java @@ -25,6 +25,7 @@ import cx.ath.matthew.debug.Debug; public class Caller { + @SuppressWarnings("unchecked") public static void main(String[] args) { try { @@ -49,7 +50,7 @@ public class Caller else { Vector<Type> lts = new Vector<Type>(); Marshalling.getJavaType(args[4],lts, -1); - Type[] ts = (Type[]) lts.toArray(new Type[0]); + Type[] ts = lts.toArray(new Type[0]); Object[] os = new Object[args.length-5]; for (int i = 5; i < args.length; i++) { if (ts[i-5] instanceof Class) { diff --git a/org/freedesktop/dbus/bin/CreateInterface.java b/org/freedesktop/dbus/bin/CreateInterface.java index 3d4203a..8621842 100644 --- a/org/freedesktop/dbus/bin/CreateInterface.java +++ b/org/freedesktop/dbus/bin/CreateInterface.java @@ -653,7 +653,7 @@ public class CreateInterface if (null != config.busname) try { DBusConnection conn = DBusConnection.getConnection(config.bus); - Introspectable in = (Introspectable) conn.getRemoteObject(config.busname, config.object, Introspectable.class); + Introspectable in = conn.getRemoteObject(config.busname, config.object, Introspectable.class); String id = in.Introspect(); if (null == id) { System.err.println("ERROR: Failed to get introspection data"); diff --git a/org/freedesktop/dbus/bin/ListDBus.java b/org/freedesktop/dbus/bin/ListDBus.java index 6e09d60..18a767b 100644 --- a/org/freedesktop/dbus/bin/ListDBus.java +++ b/org/freedesktop/dbus/bin/ListDBus.java @@ -51,7 +51,7 @@ public class ListDBus else syntax(); DBusConnection conn = DBusConnection.getConnection(connection); - DBus dbus = (DBus) conn.getRemoteObject("org.freedesktop.DBus", "/org/freedesktop/DBus", DBus.class); + DBus dbus = conn.getRemoteObject("org.freedesktop.DBus", "/org/freedesktop/DBus", DBus.class); String[] names = dbus.ListNames(); for (String s: names) { if (users) diff --git a/org/freedesktop/dbus/test/TestRemoteInterface2.java b/org/freedesktop/dbus/test/TestRemoteInterface2.java index c6dfc2b..0a03a2c 100644 --- a/org/freedesktop/dbus/test/TestRemoteInterface2.java +++ b/org/freedesktop/dbus/test/TestRemoteInterface2.java @@ -49,4 +49,6 @@ public interface TestRemoteInterface2 extends DBusInterface public TestNewInterface getNew(); @Description("Test Complex Variants") public void complexv(Variant v); + @Description("Test Introspect on a different interface") + public String Introspect(); } diff --git a/org/freedesktop/dbus/test/cross_test_client.java b/org/freedesktop/dbus/test/cross_test_client.java index 1ada4d2..a8f10a8 100644 --- a/org/freedesktop/dbus/test/cross_test_client.java +++ b/org/freedesktop/dbus/test/cross_test_client.java @@ -285,33 +285,33 @@ public class cross_test_client implements DBus.Binding.TestClient, DBusSigHandle test(DBus.Binding.Tests.class, tests, "IdentityByte", (byte) 0, (byte) 0); test(DBus.Binding.Tests.class, tests, "IdentityByte", (byte) 1, (byte) 1); test(DBus.Binding.Tests.class, tests, "IdentityByte", (byte) -1, (byte) -1); - test(DBus.Binding.Tests.class, tests, "IdentityByte", (byte) Byte.MAX_VALUE, (byte) Byte.MAX_VALUE); - test(DBus.Binding.Tests.class, tests, "IdentityByte", (byte) Byte.MIN_VALUE, (byte) Byte.MIN_VALUE); + test(DBus.Binding.Tests.class, tests, "IdentityByte", Byte.MAX_VALUE, Byte.MAX_VALUE); + test(DBus.Binding.Tests.class, tests, "IdentityByte", Byte.MIN_VALUE, Byte.MIN_VALUE); i = r.nextInt(); test(DBus.Binding.Tests.class, tests, "IdentityByte", (byte) i, (byte) i); test(DBus.Binding.Tests.class, tests, "IdentityInt16", (short) 0, (short) 0); test(DBus.Binding.Tests.class, tests, "IdentityInt16", (short) 1, (short) 1); test(DBus.Binding.Tests.class, tests, "IdentityInt16", (short) -1, (short) -1); - test(DBus.Binding.Tests.class, tests, "IdentityInt16", (short) Short.MAX_VALUE, (short) Short.MAX_VALUE); - test(DBus.Binding.Tests.class, tests, "IdentityInt16", (short) Short.MIN_VALUE, (short) Short.MIN_VALUE); + test(DBus.Binding.Tests.class, tests, "IdentityInt16", Short.MAX_VALUE, Short.MAX_VALUE); + test(DBus.Binding.Tests.class, tests, "IdentityInt16", Short.MIN_VALUE, Short.MIN_VALUE); i = r.nextInt(); test(DBus.Binding.Tests.class, tests, "IdentityInt16", (short) i, (short) i); - test(DBus.Binding.Tests.class, tests, "IdentityInt32", (int) 0, (int) 0); - test(DBus.Binding.Tests.class, tests, "IdentityInt32", (int) 1, (int) 1); - test(DBus.Binding.Tests.class, tests, "IdentityInt32", (int) -1, (int) -1); - test(DBus.Binding.Tests.class, tests, "IdentityInt32", (int) Integer.MAX_VALUE, (int) Integer.MAX_VALUE); - test(DBus.Binding.Tests.class, tests, "IdentityInt32", (int) Integer.MIN_VALUE, (int) Integer.MIN_VALUE); + test(DBus.Binding.Tests.class, tests, "IdentityInt32", 0, 0); + test(DBus.Binding.Tests.class, tests, "IdentityInt32", 1, 1); + test(DBus.Binding.Tests.class, tests, "IdentityInt32", -1, -1); + test(DBus.Binding.Tests.class, tests, "IdentityInt32", Integer.MAX_VALUE, Integer.MAX_VALUE); + test(DBus.Binding.Tests.class, tests, "IdentityInt32", Integer.MIN_VALUE, Integer.MIN_VALUE); i = r.nextInt(); - test(DBus.Binding.Tests.class, tests, "IdentityInt32", (int) i, (int) i); + test(DBus.Binding.Tests.class, tests, "IdentityInt32", i, i); test(DBus.Binding.Tests.class, tests, "IdentityInt64", (long) 0, (long) 0); test(DBus.Binding.Tests.class, tests, "IdentityInt64", (long) 1, (long) 1); test(DBus.Binding.Tests.class, tests, "IdentityInt64", (long) -1, (long) -1); - test(DBus.Binding.Tests.class, tests, "IdentityInt64", (long) Long.MAX_VALUE, (long) Long.MAX_VALUE); - test(DBus.Binding.Tests.class, tests, "IdentityInt64", (long) Long.MIN_VALUE, (long) Long.MIN_VALUE); + test(DBus.Binding.Tests.class, tests, "IdentityInt64", Long.MAX_VALUE, Long.MAX_VALUE); + test(DBus.Binding.Tests.class, tests, "IdentityInt64", Long.MIN_VALUE, Long.MIN_VALUE); i = r.nextInt(); test(DBus.Binding.Tests.class, tests, "IdentityInt64", (long) i, (long) i); @@ -485,12 +485,12 @@ public class cross_test_client implements DBus.Binding.TestClient, DBusSigHandle ctc = new cross_test_client(conn); conn.exportObject("/Test", ctc); conn.addSigHandler(DBus.Binding.TestSignals.Triggered.class, ctc); - DBus.Binding.Tests tests = (DBus.Binding.Tests) conn.getRemoteObject("org.freedesktop.DBus.Binding.TestServer", "/Test", DBus.Binding.Tests.class); - DBus.Binding.SingleTests singletests = (DBus.Binding.SingleTests) conn.getRemoteObject("org.freedesktop.DBus.Binding.TestServer", "/Test", DBus.Binding.SingleTests.class); - DBus.Peer peer = (DBus.Peer) conn.getRemoteObject("org.freedesktop.DBus.Binding.TestServer", "/Test", DBus.Peer.class); - DBus.Introspectable intro = (DBus.Introspectable) conn.getRemoteObject("org.freedesktop.DBus.Binding.TestServer", "/Test", DBus.Introspectable.class); + DBus.Binding.Tests tests = conn.getRemoteObject("org.freedesktop.DBus.Binding.TestServer", "/Test", DBus.Binding.Tests.class); + DBus.Binding.SingleTests singletests = conn.getRemoteObject("org.freedesktop.DBus.Binding.TestServer", "/Test", DBus.Binding.SingleTests.class); + DBus.Peer peer = conn.getRemoteObject("org.freedesktop.DBus.Binding.TestServer", "/Test", DBus.Peer.class); + DBus.Introspectable intro = conn.getRemoteObject("org.freedesktop.DBus.Binding.TestServer", "/Test", DBus.Introspectable.class); - DBus.Introspectable rootintro = (DBus.Introspectable) conn.getRemoteObject("org.freedesktop.DBus.Binding.TestServer", "/", DBus.Introspectable.class); + DBus.Introspectable rootintro = conn.getRemoteObject("org.freedesktop.DBus.Binding.TestServer", "/", DBus.Introspectable.class); doTests(peer, intro, rootintro, tests, singletests); diff --git a/org/freedesktop/dbus/test/cross_test_server.java b/org/freedesktop/dbus/test/cross_test_server.java index 52af457..d7e0f3c 100644 --- a/org/freedesktop/dbus/test/cross_test_server.java +++ b/org/freedesktop/dbus/test/cross_test_server.java @@ -315,7 +315,7 @@ public class cross_test_server implements DBus.Binding.Tests, DBus.Binding.Singl done.add("org.freedesktop.DBus.Binding.TestClient.Trigger"); notdone.remove("org.freedesktop.DBus.Binding.TestClient.Trigger"); try { - DBus.Binding.TestClient cb = (DBus.Binding.TestClient) conn.getRemoteObject(t.getSource(), "/Test", DBus.Binding.TestClient.class); + DBus.Binding.TestClient cb = conn.getRemoteObject(t.getSource(), "/Test", DBus.Binding.TestClient.class); cb.Response(t.a, t.b); } catch (DBusException DBe) { throw new DBusExecutionException(DBe.getMessage()); diff --git a/org/freedesktop/dbus/test/profile.java b/org/freedesktop/dbus/test/profile.java index 5a383d3..cab5417 100644 --- a/org/freedesktop/dbus/test/profile.java +++ b/org/freedesktop/dbus/test/profile.java @@ -116,7 +116,7 @@ public class profile if ("pings".equals(args[0])) { int count = PING_INNER*PING_OUTER; System.out.print("Sending "+count+" pings..."); - Peer p = (Peer) conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Peer.class); + Peer p = conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Peer.class); Log l = new Log(count); long t = System.currentTimeMillis(); for (int i = 0; i < PING_OUTER; i++) { @@ -136,7 +136,7 @@ public class profile int count = ARRAY_INNER*ARRAY_OUTER; System.out.print("Sending array of "+ARRAY_LENGTH+" ints "+count+" times."); conn.exportObject("/Profiler", new ProfilerInstance()); - Profiler p = (Profiler) conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); + Profiler p = conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); int[] v = new int[ARRAY_LENGTH]; Random r = new Random(); for (int i = 0; i < ARRAY_LENGTH; i++) v[i] = r.nextInt(); @@ -159,7 +159,7 @@ public class profile int count = MAP_INNER*MAP_OUTER; System.out.print("Sending map of "+MAP_LENGTH+" string=>strings "+count+" times."); conn.exportObject("/Profiler", new ProfilerInstance()); - Profiler p = (Profiler) conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); + Profiler p = conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); HashMap<String,String> m = new HashMap<String,String>(); for (int i = 0; i < MAP_LENGTH; i++) m.put(""+i, "hello"); @@ -182,7 +182,7 @@ public class profile int count = LIST_OUTER*LIST_INNER; System.out.print("Sending list of "+LIST_LENGTH+" strings "+count+" times."); conn.exportObject("/Profiler", new ProfilerInstance()); - Profiler p = (Profiler) conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); + Profiler p = conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); Vector<String> v = new Vector<String>(); for (int i = 0; i < LIST_LENGTH; i++) v.add("hello "+i); @@ -205,7 +205,7 @@ public class profile int count = STRUCT_OUTER*STRUCT_INNER; System.out.print("Sending a struct "+count+" times."); conn.exportObject("/Profiler", new ProfilerInstance()); - Profiler p = (Profiler) conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); + Profiler p = conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); ProfileStruct ps = new ProfileStruct("hello", new UInt32(18), 500L); Log l = new Log(count); long t = System.currentTimeMillis(); @@ -226,7 +226,7 @@ public class profile int count = INTROSPECTION_OUTER*INTROSPECTION_INNER; System.out.print("Recieving introspection data "+count+" times."); conn.exportObject("/Profiler", new ProfilerInstance()); - Introspectable is = (Introspectable) conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Introspectable.class); + Introspectable is = conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Introspectable.class); Log l = new Log(count); long t = System.currentTimeMillis(); String s = null; @@ -247,7 +247,7 @@ public class profile } else if ("bytes".equals(args[0])) { System.out.print("Sending "+BYTES+" bytes"); conn.exportObject("/Profiler", new ProfilerInstance()); - Profiler p = (Profiler) conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); + Profiler p = conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); byte[] bs = new byte[BYTES]; for (int i = 0; i < BYTES; i++) bs[i] = (byte) i; @@ -256,8 +256,8 @@ public class profile System.out.println(" done in "+(System.currentTimeMillis()-t)+"ms."); } else if ("rate".equals(args[0])) { conn.exportObject("/Profiler", new ProfilerInstance()); - Profiler p = (Profiler) conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); - Peer peer = (Peer) conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Peer.class); + Profiler p = conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Profiler.class); + Peer peer = conn.getRemoteObject("org.freedesktop.DBus.java.profiler", "/Profiler", Peer.class); long start = System.currentTimeMillis(); int count = 0; do { diff --git a/org/freedesktop/dbus/test/test.java b/org/freedesktop/dbus/test/test.java index f1d1a30..f2f4c06 100644 --- a/org/freedesktop/dbus/test/test.java +++ b/org/freedesktop/dbus/test/test.java @@ -61,6 +61,10 @@ class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignal { this.conn = conn; } + public String Introspect() + { + return "Not XML"; + } public int[][] teststructstruct(TestStruct3 in) { List<List<Integer>> lli = in.b; @@ -574,6 +578,12 @@ public class test System.out.println("Calling Method4/5/6/7"); /** This gets a remote object matching our bus name and exported object path. */ TestRemoteInterface2 tri2 = clientconn.getRemoteObject("foo.bar.Test", "/Test", TestRemoteInterface2.class); + System.out.print("Calling the other introspect method: "); + String intro2 = tri2.Introspect(); + System.out.println(intro2); + if (0 != col.compare("Not XML", intro2)) + fail("Introspect return value incorrect"); + /** Call the remote object and get a response. */ TestTuple<String,List<Integer>,Boolean> rv = tri2.show(234); System.out.println("Show returned: "+rv); diff --git a/org/freedesktop/dbus/test/two_part_test_client.java b/org/freedesktop/dbus/test/two_part_test_client.java index aafa4f7..1f132e9 100644 --- a/org/freedesktop/dbus/test/two_part_test_client.java +++ b/org/freedesktop/dbus/test/two_part_test_client.java @@ -28,7 +28,7 @@ public class two_part_test_client System.out.println("get conn"); DBusConnection conn = DBusConnection.getConnection(DBusConnection.SESSION); System.out.println("get remote"); - TwoPartInterface remote = (TwoPartInterface) conn.getRemoteObject("org.freedesktop.dbus.test.two_part_server", "/", TwoPartInterface.class); + TwoPartInterface remote = conn.getRemoteObject("org.freedesktop.dbus.test.two_part_server", "/", TwoPartInterface.class); System.out.println("get object"); TwoPartObject o = remote.getNew(); System.out.println("get name"); diff --git a/org/freedesktop/dbus/viewer/DBusViewer.java b/org/freedesktop/dbus/viewer/DBusViewer.java index 1cf8f6a..af33b88 100644 --- a/org/freedesktop/dbus/viewer/DBusViewer.java +++ b/org/freedesktop/dbus/viewer/DBusViewer.java @@ -211,7 +211,7 @@ public class DBusViewer { DBusTableModel model = new DBusTableModel(); - DBus dbus = (DBus) conn.getRemoteObject("org.freedesktop.DBus", + DBus dbus = conn.getRemoteObject("org.freedesktop.DBus", "/org/freedesktop/DBus", DBus.class); String[] names = dbus.ListNames(); @@ -299,7 +299,7 @@ public class DBusViewer DBusEntry entry = new DBusEntry(); entry.setName(name); entry.setPath(path); - Introspectable introspectable = (Introspectable) conn.getRemoteObject(name, path, Introspectable.class); + Introspectable introspectable = conn.getRemoteObject(name, path, Introspectable.class); entry.setIntrospectable(introspectable); result.add(entry); |