summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Johnson <mjj29@hecate.matthew.ath.cx>2008-02-05 10:18:37 +0000
committerMatthew Johnson <mjj29@hecate.matthew.ath.cx>2008-02-05 10:18:37 +0000
commitd5a84e681639aac6cca9b3fe50532729d2b60025 (patch)
tree95c228d6406001f96679ba68dec4fea178bbd3d8
parent1ae3c61f78a8c62c947e94c7da8656d6849e3a24 (diff)
fix warnings when building with gcj
-rw-r--r--changelog2
-rw-r--r--debug.conf6
-rw-r--r--org/freedesktop/DBus.java6
-rw-r--r--org/freedesktop/dbus/AbstractConnection.java40
-rw-r--r--org/freedesktop/dbus/ArrayFrob.java54
-rw-r--r--org/freedesktop/dbus/Container.java4
-rw-r--r--org/freedesktop/dbus/DBusAsyncReply.java6
-rw-r--r--org/freedesktop/dbus/DBusCallInfo.java2
-rw-r--r--org/freedesktop/dbus/DBusConnection.java22
-rw-r--r--org/freedesktop/dbus/DBusMap.java3
-rw-r--r--org/freedesktop/dbus/DBusMatchRule.java12
-rw-r--r--org/freedesktop/dbus/DBusSignal.java24
-rw-r--r--org/freedesktop/dbus/DirectConnection.java9
-rw-r--r--org/freedesktop/dbus/Marshalling.java92
-rw-r--r--org/freedesktop/dbus/Message.java2
-rw-r--r--org/freedesktop/dbus/MessageWriter.java1
-rw-r--r--org/freedesktop/dbus/MethodReturn.java1
-rw-r--r--org/freedesktop/dbus/RemoteInvocationHandler.java9
-rw-r--r--org/freedesktop/dbus/Struct.java6
-rw-r--r--org/freedesktop/dbus/Transport.java3
-rw-r--r--org/freedesktop/dbus/Tuple.java6
-rw-r--r--org/freedesktop/dbus/Variant.java3
-rw-r--r--org/freedesktop/dbus/bin/CreateInterface.java10
-rw-r--r--org/freedesktop/dbus/bin/DBusDaemon.java5
-rw-r--r--org/freedesktop/dbus/bin/StructStruct.java2
-rw-r--r--org/freedesktop/dbus/exceptions/UnknownTypeCodeException.java2
-rw-r--r--org/freedesktop/dbus/test/ProfileStruct.java1
-rw-r--r--org/freedesktop/dbus/test/TestNewInterface.java4
-rw-r--r--org/freedesktop/dbus/test/TestRemoteInterface2.java4
-rw-r--r--org/freedesktop/dbus/test/TestSerializable.java4
-rw-r--r--org/freedesktop/dbus/test/TestSignalInterface.java1
-rw-r--r--org/freedesktop/dbus/test/TestStruct.java4
-rw-r--r--org/freedesktop/dbus/test/TestStruct2.java4
-rw-r--r--org/freedesktop/dbus/test/TestStruct3.java1
-rw-r--r--org/freedesktop/dbus/test/cross_test_client.java38
-rw-r--r--org/freedesktop/dbus/test/cross_test_server.java12
-rw-r--r--org/freedesktop/dbus/test/profile.java2
-rw-r--r--org/freedesktop/dbus/test/test.java27
-rw-r--r--org/freedesktop/dbus/test/test_low_level.java1
-rw-r--r--org/freedesktop/dbus/test/test_p2p_server.java1
40 files changed, 200 insertions, 236 deletions
diff --git a/changelog b/changelog
index ac7b5bc..08d0c8c 100644
--- a/changelog
+++ b/changelog
@@ -21,6 +21,8 @@ Version 2.4:
* Fix utf-8 characters used in test to actually be the same character...
* Add code to preallocate the buffer array array (Suggested by Adam
Bennett <cruxic -at- gmail -dot- com>)
+ * Fix warnings when building with gcj (fixes a bug in Peer handling and
+ DBusSerializable handling)
Version 2.3.2:
diff --git a/debug.conf b/debug.conf
index c3c33bd..eb41baf 100644
--- a/debug.conf
+++ b/debug.conf
@@ -1,5 +1,5 @@
-org.freedesktop.dbus.MessageReader = ERR
-org.freedesktop.dbus.MessageWriter = ERR
+org.freedesktop.dbus.MessageReader = INFO
+org.freedesktop.dbus.MessageWriter = INFO
org.freedesktop.dbus.Message = ERR
org.freedesktop.dbus.MethodCall = ERR
org.freedesktop.dbus.MethodTuple = ERR
@@ -15,7 +15,7 @@ org.freedesktop.dbus.EfficientQueue = ERR
org.freedesktop.dbus.Transport = ERR
org.freedesktop.dbus.Transport$SASL = ERR
org.freedesktop.dbus.Transport$SASL$Command = ERR
-org.freedesktop.dbus.Marshalling = ERR
+org.freedesktop.dbus.Marshalling = VERBOSE
org.freedesktop.dbus.ObjectTree = ERR
org.freedesktop.dbus.BusAddress = ERR
org.freedesktop.dbus.RemoteInvocationHandler = ERR
diff --git a/org/freedesktop/DBus.java b/org/freedesktop/DBus.java
index 3250e4a..7be8b85 100644
--- a/org/freedesktop/DBus.java
+++ b/org/freedesktop/DBus.java
@@ -379,7 +379,7 @@ public interface DBus extends DBusInterface
public interface Tests extends DBusInterface
{
@Description("Returns whatever it is passed")
- public Variant Identity(Variant input);
+ public <T> Variant<T> Identity(Variant<T> input);
@Description("Returns whatever it is passed")
public byte IdentityByte(byte input);
@Description("Returns whatever it is passed")
@@ -401,7 +401,7 @@ public interface DBus extends DBusInterface
@Description("Returns whatever it is passed")
public String IdentityString(String input);
@Description("Returns whatever it is passed")
- public Variant[] IdentityArray(Variant[] input);
+ public <T> Variant<T>[] IdentityArray(Variant<T>[] input);
@Description("Returns whatever it is passed")
public byte[] IdentityByteArray(byte[] input);
@Description("Returns whatever it is passed")
@@ -429,7 +429,7 @@ public interface DBus extends DBusInterface
@Description("This method returns the contents of a struct as separate values")
public Triplet<String, UInt32, Short> DeStruct(TestStruct a);
@Description("Given any compound type as a variant, return all the primitive types recursively contained within as an array of variants")
- public List<Variant> Primitize(Variant a);
+ public List<Variant<Object>> Primitize(Variant<Object> a);
@Description("inverts it's input")
public boolean Invert(boolean a);
@Description("triggers sending of a signal from the supplied object with the given parameter")
diff --git a/org/freedesktop/dbus/AbstractConnection.java b/org/freedesktop/dbus/AbstractConnection.java
index de66534..1916ba6 100644
--- a/org/freedesktop/dbus/AbstractConnection.java
+++ b/org/freedesktop/dbus/AbstractConnection.java
@@ -37,7 +37,6 @@ import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
import org.freedesktop.dbus.exceptions.FatalDBusException;
import org.freedesktop.dbus.exceptions.FatalException;
-import org.freedesktop.dbus.exceptions.NonFatalException;
import cx.ath.matthew.debug.Debug;
@@ -233,10 +232,10 @@ public abstract class AbstractConnection
private ObjectTree objectTree;
private _globalhandler _globalhandlerreference;
protected Map<DBusInterface,RemoteObject> importedObjects;
- protected Map<SignalTuple,Vector<DBusSigHandler>> handledSignals;
+ protected Map<SignalTuple,Vector<DBusSigHandler<? extends DBusSignal>>> handledSignals;
protected EfficientMap pendingCalls;
- protected Map<MethodCall, CallbackHandler> pendingCallbacks;
- protected Map<MethodCall, DBusAsyncReply> pendingCallbackReplys;
+ protected Map<MethodCall, CallbackHandler<? extends Object>> pendingCallbacks;
+ protected Map<MethodCall, DBusAsyncReply<? extends Object>> pendingCallbackReplys;
protected LinkedList<Runnable> runnables;
protected LinkedList<_workerthread> workers;
protected FallbackContainer fallbackcontainer;
@@ -282,11 +281,11 @@ public abstract class AbstractConnection
synchronized (exportedObjects) {
exportedObjects.put(null, new ExportedObject(_globalhandlerreference));
}
- handledSignals = new HashMap<SignalTuple,Vector<DBusSigHandler>>();
+ handledSignals = new HashMap<SignalTuple,Vector<DBusSigHandler<? extends DBusSignal>>>();
pendingCalls = new EfficientMap(PENDING_MAP_INITIAL_SIZE);
outgoing = new EfficientQueue(PENDING_MAP_INITIAL_SIZE);
- pendingCallbacks = new HashMap<MethodCall, CallbackHandler>();
- pendingCallbackReplys = new HashMap<MethodCall, DBusAsyncReply>();
+ pendingCallbacks = new HashMap<MethodCall, CallbackHandler<? extends Object>>();
+ pendingCallbackReplys = new HashMap<MethodCall, DBusAsyncReply<? extends Object>>();
pendingErrors = new LinkedList<Error>();
runnables = new LinkedList<Runnable>();
workers = new LinkedList<_workerthread>();
@@ -502,10 +501,11 @@ public abstract class AbstractConnection
* @throws DBusException If listening for the signal on the bus failed.
* @throws ClassCastException If type is not a sub-type of DBusSignal.
*/
+ @SuppressWarnings("unchecked")
public <T extends DBusSignal> void addSigHandler(Class<T> type, DBusSigHandler<T> handler) throws DBusException
{
if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
- addSigHandler(new DBusMatchRule(type), handler);
+ addSigHandler(new DBusMatchRule(type), (DBusSigHandler<? extends DBusSignal>) handler);
}
/**
* Add a Signal Handler.
@@ -515,26 +515,27 @@ public abstract class AbstractConnection
* @param handler The handler to call when a signal is received.
* @throws DBusException If listening for the signal on the bus failed.
* @throws ClassCastException If type is not a sub-type of DBusSignal.
- */
+ */
+ @SuppressWarnings("unchecked")
public <T extends DBusSignal> void addSigHandler(Class<T> type, DBusInterface object, DBusSigHandler<T> handler) throws DBusException
{
if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
String objectpath = importedObjects.get(object).objectpath;
if (!objectpath.matches(OBJECT_REGEX)||objectpath.length() > MAX_NAME_LENGTH)
throw new DBusException(_("Invalid object path: ")+objectpath);
- addSigHandler(new DBusMatchRule(type, null, objectpath), handler);
+ addSigHandler(new DBusMatchRule(type, null, objectpath), (DBusSigHandler<? extends DBusSignal>) handler);
}
protected abstract <T extends DBusSignal> void addSigHandler(DBusMatchRule rule, DBusSigHandler<T> handler) throws DBusException;
- protected void addSigHandlerWithoutMatch(Class signal, DBusSigHandler handler) throws DBusException
+ protected <T extends DBusSignal> void addSigHandlerWithoutMatch(Class<? extends DBusSignal> signal, DBusSigHandler<T> handler) throws DBusException
{
DBusMatchRule rule = new DBusMatchRule(signal);
SignalTuple key = new SignalTuple(rule.getInterface(), rule.getMember(), rule.getObject(), rule.getSource());
synchronized (handledSignals) {
- Vector<DBusSigHandler> v = handledSignals.get(key);
+ Vector<DBusSigHandler<? extends DBusSignal>> v = handledSignals.get(key);
if (null == v) {
- v = new Vector<DBusSigHandler>();
+ v = new Vector<DBusSigHandler<? extends DBusSignal>>();
v.add(handler);
handledSignals.put(key, v);
} else
@@ -638,9 +639,10 @@ public abstract class AbstractConnection
* @param parameters The parameters to call the method with.
* @return A handle to the call.
*/
+ @SuppressWarnings("unchecked")
public DBusAsyncReply callMethodAsync(DBusInterface object, String m, Object... parameters)
{
- Class[] types = new Class[parameters.length];
+ Class<?>[] types = new Class[parameters.length];
for (int i = 0; i < parameters.length; i++)
types[i] = parameters[i].getClass();
RemoteObject ro = importedObjects.get(object);
@@ -664,8 +666,6 @@ public abstract class AbstractConnection
private void handleMessage(final MethodCall m) throws DBusException
{
if (Debug.debug) Debug.print(Debug.DEBUG, "Handling incoming method call: "+m);
- // get the method signature
- Object[] params = m.getParameters();
ExportedObject eo = null;
Method meth = null;
@@ -801,9 +801,9 @@ public abstract class AbstractConnection
private void handleMessage(final DBusSignal s)
{
if (Debug.debug) Debug.print(Debug.DEBUG, "Handling incoming signal: "+s);
- Vector<DBusSigHandler> v = new Vector<DBusSigHandler>();
+ Vector<DBusSigHandler<? extends DBusSignal>> v = new Vector<DBusSigHandler<? extends DBusSignal>>();
synchronized(handledSignals) {
- Vector<DBusSigHandler> t;
+ Vector<DBusSigHandler<? extends DBusSignal>> t;
t = handledSignals.get(new SignalTuple(s.getInterface(), s.getName(), null, null));
if (null != t) v.addAll(t);
t = handledSignals.get(new SignalTuple(s.getInterface(), s.getName(), s.getPath(), null));
@@ -815,7 +815,7 @@ public abstract class AbstractConnection
}
if (0 == v.size()) return;
final AbstractConnection conn = this;
- for (final DBusSigHandler h: v) {
+ for (final DBusSigHandler<? extends DBusSignal> h: v) {
if (Debug.debug) Debug.print(Debug.VERBOSE, "Adding Runnable for signal "+s+" with handler "+h);
addRunnable(new Runnable() {
private boolean run = false;
@@ -829,7 +829,7 @@ public abstract class AbstractConnection
rs = s.createReal(conn);
else
rs = s;
- h.handle(rs);
+ ((DBusSigHandler<DBusSignal>)h).handle(rs);
} catch (DBusException DBe) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
try {
diff --git a/org/freedesktop/dbus/ArrayFrob.java b/org/freedesktop/dbus/ArrayFrob.java
index 4e63bca..5a9e14a 100644
--- a/org/freedesktop/dbus/ArrayFrob.java
+++ b/org/freedesktop/dbus/ArrayFrob.java
@@ -13,8 +13,6 @@ package org.freedesktop.dbus;
import static org.freedesktop.dbus.Gettext._;
import java.lang.reflect.Array;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -25,8 +23,8 @@ import cx.ath.matthew.debug.Debug;
class ArrayFrob
{
- static Hashtable<Class, Class> primitiveToWrapper = new Hashtable<Class, Class>();
- static Hashtable<Class, Class> wrapperToPrimitive = new Hashtable<Class, Class>();
+ static Hashtable<Class<? extends Object>, Class<? extends Object>> primitiveToWrapper = new Hashtable<Class<? extends Object>, Class<? extends Object>>();
+ static Hashtable<Class<? extends Object>, Class<? extends Object>> wrapperToPrimitive = new Hashtable<Class<? extends Object>, Class<? extends Object>>();
static {
primitiveToWrapper.put( Boolean.TYPE, Boolean.class );
primitiveToWrapper.put( Byte.TYPE, Byte.class );
@@ -46,54 +44,58 @@ class ArrayFrob
wrapperToPrimitive.put( Double.class, Double.TYPE );
}
- public static Object[] wrap(Object o) throws IllegalArgumentException
+ @SuppressWarnings("unchecked")
+ public static <T> T[] wrap(Object o) throws IllegalArgumentException
{
- Class ac = o.getClass();
+ Class<? extends Object> ac = o.getClass();
if (!ac.isArray()) throw new IllegalArgumentException(_("Not an array"));
- Class cc = ac.getComponentType();
- Class ncc = primitiveToWrapper.get(cc);
+ Class<? extends Object> cc = ac.getComponentType();
+ Class<? extends Object> ncc = primitiveToWrapper.get(cc);
if (null == ncc) throw new IllegalArgumentException(_("Not a primitive type"));
- Object[] ns = (Object[]) Array.newInstance(ncc, Array.getLength(o));
+ T[] ns = (T[]) Array.newInstance(ncc, Array.getLength(o));
for (int i = 0; i < ns.length; i++)
- ns[i] = Array.get(o, i);
+ ns[i] = (T) Array.get(o, i);
return ns;
}
- public static Object unwrap(Object[] ns) throws IllegalArgumentException
+ @SuppressWarnings("unchecked")
+ public static <T> Object unwrap(T[] ns) throws IllegalArgumentException
{
- Class<? extends Object[]> ac = ns.getClass();
- Class cc = ac.getComponentType();
- Class ncc = wrapperToPrimitive.get(cc);
+ Class<? extends T[]> ac = (Class<? extends T[]>) ns.getClass();
+ Class<T> cc = (Class<T>) ac.getComponentType();
+ Class<? extends Object> ncc = wrapperToPrimitive.get(cc);
if (null == ncc) throw new IllegalArgumentException(_("Not a wrapper type"));
Object o = Array.newInstance(ncc, ns.length);
for (int i = 0; i < ns.length; i++)
Array.set(o, i, ns[i]);
return o;
}
- public static List listify(Object[] ns) throws IllegalArgumentException
+ public static <T> List<T> listify(T[] ns) throws IllegalArgumentException
{
return Arrays.asList(ns);
}
- public static List listify(Object o) throws IllegalArgumentException
+ @SuppressWarnings("unchecked")
+ public static <T> List<T> listify(Object o) throws IllegalArgumentException
{
- if (o instanceof Object[]) return listify((Object[]) o);
+ if (o instanceof Object[]) return listify((T[]) o);
if (!o.getClass().isArray()) throw new IllegalArgumentException(_("Not an array"));
- List<Object> l = new ArrayList<Object>(Array.getLength(o));
+ List<T> l = new ArrayList<T>(Array.getLength(o));
for (int i = 0; i < Array.getLength(o); i++)
- l.add(Array.get(o, i));
+ l.add((T)Array.get(o, i));
return l;
}
@SuppressWarnings("unchecked")
- public static <T> T[] delist(List l, Class<T> c) throws IllegalArgumentException
+ public static <T> T[] delist(List<T> l, Class<T> c) throws IllegalArgumentException
{
- return (T[]) l.toArray((T[]) Array.newInstance(c, 0));
+ return l.toArray((T[]) Array.newInstance(c, 0));
}
- public static Object delistprimitive(List l, Class c) throws IllegalArgumentException
+ public static <T> Object delistprimitive(List<T> l, Class<T> c) throws IllegalArgumentException
{
Object o = Array.newInstance(c, l.size());
for (int i = 0; i < l.size(); i++)
Array.set(o, i, l.get(i));
return o;
}
+ @SuppressWarnings("unchecked")
public static Object convert(Object o, Class<? extends Object> c) throws IllegalArgumentException
{
/* Possible Conversions:
@@ -143,16 +145,16 @@ class ArrayFrob
if (o instanceof List
&& c.isArray()
&& c.getComponentType().isPrimitive())
- return delistprimitive((List) o, c.getComponentType());
+ return delistprimitive((List<Object>) o, (Class<Object>) c.getComponentType());
// List<Integer> -> Integer[]
if (o instanceof List
&& c.isArray())
- return delist((List) o, c.getComponentType());
+ return delist((List<Object>) o, (Class<Object>) c.getComponentType());
if (o.getClass().isArray()
&& c.isArray())
- return type((Object[]) o, c.getComponentType());
+ return type((Object[]) o, (Class<Object>) c.getComponentType());
} catch (Exception e) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
@@ -161,7 +163,7 @@ class ArrayFrob
throw new IllegalArgumentException(MessageFormat.format(_("Not An Expected Convertion type from {0} to {1}"), new Object[] { o.getClass(), c}));
}
- public static Object[] type(Object[] old, Class c)
+ public static Object[] type(Object[] old, Class<Object> c)
{
Object[] ns = (Object[]) Array.newInstance(c, old.length);
for (int i = 0; i < ns.length; i++)
diff --git a/org/freedesktop/dbus/Container.java b/org/freedesktop/dbus/Container.java
index c3c72c6..55df41d 100644
--- a/org/freedesktop/dbus/Container.java
+++ b/org/freedesktop/dbus/Container.java
@@ -15,9 +15,6 @@ import java.util.HashMap;
import java.util.Map;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-
-import org.freedesktop.dbus.exceptions.DBusException;
/**
* This class is the super class of both Structs and Tuples
@@ -34,7 +31,6 @@ abstract class Container
{
return typecache.get(k);
}
- private String sig = null;
private Object[] parameters = null;
public Container() {}
private void setup()
diff --git a/org/freedesktop/dbus/DBusAsyncReply.java b/org/freedesktop/dbus/DBusAsyncReply.java
index 86a6087..cd277a6 100644
--- a/org/freedesktop/dbus/DBusAsyncReply.java
+++ b/org/freedesktop/dbus/DBusAsyncReply.java
@@ -33,10 +33,10 @@ public class DBusAsyncReply<ReturnType>
* @param replies A Collection of handles to replies to check.
* @return A Collection only containing those calls which have had replies.
*/
- public static Collection<DBusAsyncReply> hasReply(Collection<DBusAsyncReply> replies)
+ public static Collection<DBusAsyncReply<? extends Object>> hasReply(Collection<DBusAsyncReply<? extends Object>> replies)
{
- Collection<DBusAsyncReply> c = new ArrayList<DBusAsyncReply>(replies);
- Iterator<DBusAsyncReply> i = c.iterator();
+ Collection<DBusAsyncReply<? extends Object>> c = new ArrayList<DBusAsyncReply<? extends Object>>(replies);
+ Iterator<DBusAsyncReply<? extends Object>> i = c.iterator();
while (i.hasNext())
if (!i.next().hasReply()) i.remove();
return c;
diff --git a/org/freedesktop/dbus/DBusCallInfo.java b/org/freedesktop/dbus/DBusCallInfo.java
index d84fc59..df1a67b 100644
--- a/org/freedesktop/dbus/DBusCallInfo.java
+++ b/org/freedesktop/dbus/DBusCallInfo.java
@@ -19,7 +19,7 @@ public class DBusCallInfo
* Indicates the caller won't wait for a reply (and we won't send one).
*/
public static final int NO_REPLY = Message.Flags.NO_REPLY_EXPECTED;
- private static final int ASYNC = 0x100;
+ public static final int ASYNC = 0x100;
private String source;
private String destination;
private String objectpath;
diff --git a/org/freedesktop/dbus/DBusConnection.java b/org/freedesktop/dbus/DBusConnection.java
index 3fa5456..3fc6007 100644
--- a/org/freedesktop/dbus/DBusConnection.java
+++ b/org/freedesktop/dbus/DBusConnection.java
@@ -12,10 +12,7 @@ package org.freedesktop.dbus;
import static org.freedesktop.dbus.Gettext._;
-import java.lang.ref.WeakReference;
-
import java.lang.reflect.Proxy;
-import java.lang.reflect.Type;
import java.io.IOException;
@@ -46,7 +43,7 @@ import cx.ath.matthew.debug.Debug;
*/
public class DBusConnection extends AbstractConnection
{
- private class _sighandler implements DBusSigHandler
+ private class _sighandler implements DBusSigHandler<DBusSignal>
{
public void handle(DBusSignal s)
{
@@ -89,7 +86,6 @@ public class DBusConnection extends AbstractConnection
private static final Map<Object,DBusConnection> conn = new HashMap<Object,DBusConnection>();
private int _refcount = 0;
private Object _reflock = new Object();
- private Object connkey;
private DBus _dbus;
/**
@@ -199,7 +195,7 @@ public class DBusConnection extends AbstractConnection
ifaces.add(tag.replaceAll("^interface *name *= *['\"]([^'\"]*)['\"].*$", "$1"));
}
}
- Vector<Class> ifcs = new Vector<Class>();
+ Vector<Class<? extends Object>> ifcs = new Vector<Class<? extends Object>>();
for(String iface: ifaces) {
int j = 0;
while (j >= 0) {
@@ -327,7 +323,7 @@ public class DBusConnection extends AbstractConnection
String unique = _dbus.GetNameOwner(busname);
- return dynamicProxy(busname, objectpath);
+ return dynamicProxy(unique, objectpath);
}
/**
@@ -499,7 +495,7 @@ public class DBusConnection extends AbstractConnection
SignalTuple key = new SignalTuple(rule.getInterface(), rule.getMember(), rule.getObject(), rule.getSource());
synchronized (handledSignals) {
- Vector<DBusSigHandler> v = handledSignals.get(key);
+ Vector<DBusSigHandler<? extends DBusSignal>> v = handledSignals.get(key);
if (null != v) {
v.remove(handler);
if (0 == v.size()) {
@@ -523,13 +519,14 @@ public class DBusConnection extends AbstractConnection
* @throws DBusException If listening for the signal on the bus failed.
* @throws ClassCastException If type is not a sub-type of DBusSignal.
*/
+ @SuppressWarnings("unchecked")
public <T extends DBusSignal> void addSigHandler(Class<T> type, String source, DBusSigHandler<T> handler) throws DBusException
{
if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
if (source.matches(BUSNAME_REGEX)) throw new DBusException(_("Cannot watch for signals based on well known bus name as source, only unique names."));
if (!source.matches(CONNID_REGEX)||source.length() > MAX_NAME_LENGTH)
throw new DBusException(_("Invalid bus name: ")+source);
- addSigHandler(new DBusMatchRule(type, source, null), handler);
+ addSigHandler(new DBusMatchRule(type, source, null), (DBusSigHandler<? extends DBusSignal>) handler);
}
/**
* Add a Signal Handler.
@@ -541,6 +538,7 @@ public class DBusConnection extends AbstractConnection
* @throws DBusException If listening for the signal on the bus failed.
* @throws ClassCastException If type is not a sub-type of DBusSignal.
*/
+ @SuppressWarnings("unchecked")
public <T extends DBusSignal> void addSigHandler(Class<T> type, String source, DBusInterface object, DBusSigHandler<T> handler) throws DBusException
{
if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
@@ -550,7 +548,7 @@ public class DBusConnection extends AbstractConnection
String objectpath = importedObjects.get(object).objectpath;
if (!objectpath.matches(OBJECT_REGEX)||objectpath.length() > MAX_NAME_LENGTH)
throw new DBusException(_("Invalid object path: ")+objectpath);
- addSigHandler(new DBusMatchRule(type, source, objectpath), handler);
+ addSigHandler(new DBusMatchRule(type, source, objectpath), (DBusSigHandler<? extends DBusSignal>) handler);
}
protected <T extends DBusSignal> void addSigHandler(DBusMatchRule rule, DBusSigHandler<T> handler) throws DBusException
{
@@ -562,9 +560,9 @@ public class DBusConnection extends AbstractConnection
}
SignalTuple key = new SignalTuple(rule.getInterface(), rule.getMember(), rule.getObject(), rule.getSource());
synchronized (handledSignals) {
- Vector<DBusSigHandler> v = handledSignals.get(key);
+ Vector<DBusSigHandler<? extends DBusSignal>> v = handledSignals.get(key);
if (null == v) {
- v = new Vector<DBusSigHandler>();
+ v = new Vector<DBusSigHandler<? extends DBusSignal>>();
v.add(handler);
handledSignals.put(key, v);
} else
diff --git a/org/freedesktop/dbus/DBusMap.java b/org/freedesktop/dbus/DBusMap.java
index 2bb5fbc..821ac72 100644
--- a/org/freedesktop/dbus/DBusMap.java
+++ b/org/freedesktop/dbus/DBusMap.java
@@ -135,11 +135,12 @@ class DBusMap<K, V> implements Map<K, V>
{
return Arrays.deepHashCode(entries);
}
+ @SuppressWarnings("unchecked")
public boolean equals(Object o)
{
if (null == o) return false;
if (!(o instanceof Map)) return false;
- return ((Map) o).entrySet().equals(entrySet());
+ return ((Map<K,V>) o).entrySet().equals(entrySet());
}
public String toString()
{
diff --git a/org/freedesktop/dbus/DBusMatchRule.java b/org/freedesktop/dbus/DBusMatchRule.java
index 3c0501a..76afd91 100644
--- a/org/freedesktop/dbus/DBusMatchRule.java
+++ b/org/freedesktop/dbus/DBusMatchRule.java
@@ -56,18 +56,18 @@ public class DBusMatchRule
member = method;
type = "method_call";
}
- public DBusMatchRule(Class c, String source, String object) throws DBusException
+ public DBusMatchRule(Class<? extends Object> c, String source, String object) throws DBusException
{
this(c);
this.source = source;
this.object = object;
}
@SuppressWarnings("unchecked")
- public DBusMatchRule(Class c) throws DBusException
+ public DBusMatchRule(Class<? extends Object> c) throws DBusException
{
if (DBusInterface.class.isAssignableFrom(c)) {
if (null != c.getAnnotation(DBusInterfaceName.class))
- iface = ((DBusInterfaceName) c.getAnnotation(DBusInterfaceName.class)).value();
+ iface = c.getAnnotation(DBusInterfaceName.class).value();
else
iface = AbstractConnection.dollar_pattern.matcher(c.getName()).replaceAll(".");
if (!iface.matches(".*\\..*"))
@@ -80,21 +80,21 @@ public class DBusMatchRule
throw new DBusException(_("Signals must be declared as a member of a class implementing DBusInterface which is the member of a package."));
else
if (null != c.getEnclosingClass().getAnnotation(DBusInterfaceName.class))
- iface = ((DBusInterfaceName) c.getEnclosingClass().getAnnotation(DBusInterfaceName.class)).value();
+ iface = c.getEnclosingClass().getAnnotation(DBusInterfaceName.class).value();
else
iface = AbstractConnection.dollar_pattern.matcher(c.getEnclosingClass().getName()).replaceAll(".");
// Don't export things which are invalid D-Bus interfaces
if (!iface.matches(".*\\..*"))
throw new DBusException(_("DBusInterfaces must be defined in a package."));
if (c.isAnnotationPresent(DBusMemberName.class))
- member = ((DBusMemberName) c.getAnnotation(DBusMemberName.class)).value();
+ member = c.getAnnotation(DBusMemberName.class).value();
else
member = c.getSimpleName();
type = "signal";
}
else if (Error.class.isAssignableFrom(c)) {
if (null != c.getAnnotation(DBusInterfaceName.class))
- iface = ((DBusInterfaceName) c.getAnnotation(DBusInterfaceName.class)).value();
+ iface = c.getAnnotation(DBusInterfaceName.class).value();
else
iface = AbstractConnection.dollar_pattern.matcher(c.getName()).replaceAll(".");
if (!iface.matches(".*\\..*"))
diff --git a/org/freedesktop/dbus/DBusSignal.java b/org/freedesktop/dbus/DBusSignal.java
index d7643d6..bc8ec52 100644
--- a/org/freedesktop/dbus/DBusSignal.java
+++ b/org/freedesktop/dbus/DBusSignal.java
@@ -13,6 +13,7 @@ package org.freedesktop.dbus;
import static org.freedesktop.dbus.Gettext._;
import java.lang.reflect.Constructor;
+import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.Arrays;
@@ -71,8 +72,8 @@ public class DBusSignal extends Message
super(source, objectpath, type, name, sig, parameters, serial);
}
}
- private static Map<Class, Type[]> typeCache = new HashMap<Class, Type[]>();
- private static Map<Class, Constructor> conCache = new HashMap<Class, Constructor>();
+ private static Map<Class<? extends DBusSignal>, Type[]> typeCache = new HashMap<Class<? extends DBusSignal>, Type[]>();
+ private static Map<Class<? extends DBusSignal>, Constructor<? extends DBusSignal>> conCache = new HashMap<Class<? extends DBusSignal>, Constructor<? extends DBusSignal>>();
private static Map<String, String> signames = new HashMap<String, String>();
private static Map<String, String> intnames = new HashMap<String, String>();
private Class<? extends DBusSignal> c;
@@ -115,6 +116,7 @@ public class DBusSignal extends Message
} while (null == c && name.matches(".*\\..*"));
return c;
}
+ @SuppressWarnings("unchecked")
DBusSignal createReal(AbstractConnection conn) throws DBusException
{
String intname = intnames.get(getInterface());
@@ -125,15 +127,15 @@ public class DBusSignal extends Message
c = createSignalClass(intname+"$"+signame);
if (Debug.debug) Debug.print(Debug.DEBUG, "Converting signal to type: "+c);
Type[] types = typeCache.get(c);
- Constructor con = conCache.get(c);
+ Constructor<? extends DBusSignal> con = conCache.get(c);
if (null == types) {
- con = c.getDeclaredConstructors()[0];
+ con = (Constructor<? extends DBusSignal>) c.getDeclaredConstructors()[0];
conCache.put(c, con);
Type[] ts = con.getGenericParameterTypes();
types = new Type[ts.length-1];
for (int i = 1; i < ts.length; i++)
if (ts[i] instanceof TypeVariable)
- for (Type b: ((TypeVariable) ts[i]).getBounds())
+ for (Type b: ((TypeVariable<GenericDeclaration>) ts[i]).getBounds())
types[i-1] = b;
else
types[i-1] = ts[i];
@@ -175,21 +177,21 @@ public class DBusSignal extends Message
if (!objectpath.matches(AbstractConnection.OBJECT_REGEX)) throw new DBusException(_("Invalid object path: ")+objectpath);
- Class tc = getClass();
+ Class<? extends DBusSignal> tc = getClass();
String member;
if (tc.isAnnotationPresent(DBusMemberName.class))
- member = ((DBusMemberName) tc.getAnnotation(DBusMemberName.class)).value();
+ member = tc.getAnnotation(DBusMemberName.class).value();
else
member = tc.getSimpleName();
String iface = null;
- Class enc = tc.getEnclosingClass();
+ Class<? extends Object> enc = tc.getEnclosingClass();
if (null == enc ||
!DBusInterface.class.isAssignableFrom(enc) ||
enc.getName().equals(enc.getSimpleName()))
throw new DBusException(_("Signals must be declared as a member of a class implementing DBusInterface which is the member of a package."));
else
if (null != enc.getAnnotation(DBusInterfaceName.class))
- iface = ((DBusInterfaceName) enc.getAnnotation(DBusInterfaceName.class)).value();
+ iface = enc.getAnnotation(DBusInterfaceName.class).value();
else
iface = AbstractConnection.dollar_pattern.matcher(enc.getName()).replaceAll(".");
@@ -207,13 +209,13 @@ public class DBusSignal extends Message
try {
Type[] types = typeCache.get(tc);
if (null == types) {
- Constructor con = tc.getDeclaredConstructors()[0];
+ Constructor<? extends DBusSignal> con = (Constructor<? extends DBusSignal>) tc.getDeclaredConstructors()[0];
conCache.put(tc, con);
Type[] ts = con.getGenericParameterTypes();
types = new Type[ts.length-1];
for (int i = 1; i <= types.length; i++)
if (ts[i] instanceof TypeVariable)
- types[i-1] = ((TypeVariable) ts[i]).getBounds()[0];
+ types[i-1] = ((TypeVariable<GenericDeclaration>) ts[i]).getBounds()[0];
else
types[i-1] = ts[i];
typeCache.put(tc, types);
diff --git a/org/freedesktop/dbus/DirectConnection.java b/org/freedesktop/dbus/DirectConnection.java
index bdcd6e9..010d071 100644
--- a/org/freedesktop/dbus/DirectConnection.java
+++ b/org/freedesktop/dbus/DirectConnection.java
@@ -12,7 +12,6 @@ package org.freedesktop.dbus;
import static org.freedesktop.dbus.Gettext._;
-import java.lang.ref.WeakReference;
import java.lang.reflect.Proxy;
import java.io.File;
import java.io.IOException;
@@ -111,7 +110,7 @@ public class DirectConnection extends AbstractConnection
ifaces.add(tag.replaceAll("^interface *name *= *['\"]([^'\"]*)['\"].*$", "$1"));
}
}
- Vector<Class> ifcs = new Vector<Class>();
+ Vector<Class<? extends Object>> ifcs = new Vector<Class<? extends Object>>();
for(String iface: ifaces) {
int j = 0;
while (j >= 0) {
@@ -222,7 +221,7 @@ public class DirectConnection extends AbstractConnection
{
SignalTuple key = new SignalTuple(rule.getInterface(), rule.getMember(), rule.getObject(), rule.getSource());
synchronized (handledSignals) {
- Vector<DBusSigHandler> v = handledSignals.get(key);
+ Vector<DBusSigHandler<? extends DBusSignal>> v = handledSignals.get(key);
if (null != v) {
v.remove(handler);
if (0 == v.size()) {
@@ -235,9 +234,9 @@ public class DirectConnection extends AbstractConnection
{
SignalTuple key = new SignalTuple(rule.getInterface(), rule.getMember(), rule.getObject(), rule.getSource());
synchronized (handledSignals) {
- Vector<DBusSigHandler> v = handledSignals.get(key);
+ Vector<DBusSigHandler<? extends DBusSignal>> v = handledSignals.get(key);
if (null == v) {
- v = new Vector<DBusSigHandler>();
+ v = new Vector<DBusSigHandler<? extends DBusSignal>>();
v.add(handler);
handledSignals.put(key, v);
} else
diff --git a/org/freedesktop/dbus/Marshalling.java b/org/freedesktop/dbus/Marshalling.java
index 03a54de..1d338cd 100644
--- a/org/freedesktop/dbus/Marshalling.java
+++ b/org/freedesktop/dbus/Marshalling.java
@@ -86,6 +86,7 @@ public class Marshalling
return recursiveGetDBusType(c, basic, 0);
}
private static StringBuffer[] out = new StringBuffer[10];
+ @SuppressWarnings("unchecked")
public static String[] recursiveGetDBusType(Type c, boolean basic, int level) throws DBusException
{
if (out.length <= level) {
@@ -105,7 +106,32 @@ public class Marshalling
String[] s = recursiveGetDBusType(((GenericArrayType) c).getGenericComponentType(), false, level+1);
if (s.length != 1) throw new DBusException(_("Multi-valued array types not permitted"));
out[level].append(s[0]);
- }
+ } else if ((c instanceof Class &&
+ DBusSerializable.class.isAssignableFrom((Class<? extends Object>) c)) ||
+ (c instanceof ParameterizedType &&
+ DBusSerializable.class.isAssignableFrom((Class<? extends Object>) ((ParameterizedType) c).getRawType()))) {
+ // it's a custom serializable type
+ Type[] newtypes = null;
+ if (c instanceof Class) {
+ for (Method m: ((Class<? extends Object>) c).getDeclaredMethods())
+ if (m.getName().equals("deserialize"))
+ newtypes = m.getGenericParameterTypes();
+ }
+ else
+ for (Method m: ((Class<? extends Object>) ((ParameterizedType) c).getRawType()).getDeclaredMethods())
+ if (m.getName().equals("deserialize"))
+ newtypes = m.getGenericParameterTypes();
+
+ if (null == newtypes) throw new DBusException(_("Serializable classes must implement a deserialize method"));
+
+ String[] sigs = new String[newtypes.length];
+ for (int j = 0; j < sigs.length; j++) {
+ String[] ss = recursiveGetDBusType(newtypes[j], false, level+1);
+ if (1 != ss.length) throw new DBusException(_("Serializable classes must serialize to native DBus types"));
+ sigs[j] = ss[0];
+ }
+ return sigs;
+ }
else if (c instanceof ParameterizedType) {
ParameterizedType p = (ParameterizedType) c;
if (p.getRawType().equals(Map.class)) {
@@ -124,7 +150,7 @@ public class Marshalling
}
out[level].append('}');
}
- else if (List.class.isAssignableFrom((Class) p.getRawType())) {
+ else if (List.class.isAssignableFrom((Class<? extends Object>) p.getRawType())) {
for (Type t: p.getActualTypeArguments()) {
if (Type.class.equals(t))
out[level].append((char) Message.ArgumentType.SIGNATURE);
@@ -139,10 +165,10 @@ public class Marshalling
else if (p.getRawType().equals(Variant.class)) {
out[level].append((char) Message.ArgumentType.VARIANT);
}
- else if (DBusInterface.class.isAssignableFrom((Class) p.getRawType())) {
+ else if (DBusInterface.class.isAssignableFrom((Class<? extends Object>) p.getRawType())) {
out[level].append((char) Message.ArgumentType.OBJECT_PATH);
}
- else if (Tuple.class.isAssignableFrom((Class) p.getRawType())) {
+ else if (Tuple.class.isAssignableFrom((Class<? extends Object>) p.getRawType())) {
Type[] ts = p.getActualTypeArguments();
Vector<String> vs = new Vector<String>();
for (Type t: ts)
@@ -176,26 +202,27 @@ public class Marshalling
else if (c.equals(String.class)) out[level].append((char) Message.ArgumentType.STRING);
else if (c.equals(Variant.class)) out[level].append((char) Message.ArgumentType.VARIANT);
else if (c instanceof Class &&
- DBusInterface.class.isAssignableFrom((Class) c)) out[level].append((char) Message.ArgumentType.OBJECT_PATH);
+ DBusInterface.class.isAssignableFrom((Class<? extends Object>) c)) out[level].append((char) Message.ArgumentType.OBJECT_PATH);
+ else if (c instanceof Class &&
+ Path.class.equals((Class<? extends Object>) c)) out[level].append((char) Message.ArgumentType.OBJECT_PATH);
else if (c instanceof Class &&
- Path.class.equals((Class) c)) out[level].append((char) Message.ArgumentType.OBJECT_PATH);
+ ObjectPath.class.equals((Class<? extends Object>) c)) out[level].append((char) Message.ArgumentType.OBJECT_PATH);
else if (c instanceof Class &&
- ObjectPath.class.equals((Class) c)) out[level].append((char) Message.ArgumentType.OBJECT_PATH);
- else if (c instanceof Class && ((Class) c).isArray()) {
- if (Type.class.equals(((Class) c).getComponentType()))
+ ((Class<? extends Object>) c).isArray()) {
+ if (Type.class.equals(((Class<? extends Object>) c).getComponentType()))
out[level].append((char) Message.ArgumentType.SIGNATURE);
else {
out[level].append((char) Message.ArgumentType.ARRAY);
- String[] s = recursiveGetDBusType(((Class) c).getComponentType(), false, level+1);
+ String[] s = recursiveGetDBusType(((Class<? extends Object>) c).getComponentType(), false, level+1);
if (s.length != 1) throw new DBusException(_("Multi-valued array types not permitted"));
out[level].append(s[0]);
}
} else if (c instanceof Class &&
- Struct.class.isAssignableFrom((Class) c)) {
+ Struct.class.isAssignableFrom((Class<? extends Object>) c)) {
out[level].append((char) Message.ArgumentType.STRUCT1);
Type[] ts = Container.getTypeCache(c);
if (null == ts) {
- Field[] fs = ((Class) c).getDeclaredFields();
+ Field[] fs = ((Class<? extends Object>) c).getDeclaredFields();
ts = new Type[fs.length];
for (Field f : fs) {
Position p = f.getAnnotation(Position.class);
@@ -210,31 +237,6 @@ public class Marshalling
for (String s: recursiveGetDBusType(t, false, level+1))
out[level].append(s);
out[level].append(')');
- } else if ((c instanceof Class &&
- DBusSerializable.class.isAssignableFrom((Class) c)) ||
- (c instanceof ParameterizedType &&
- DBusSerializable.class.isAssignableFrom((Class) ((ParameterizedType) c).getRawType()))) {
- // it's a custom serializable type
- Type[] newtypes = null;
- if (c instanceof Class) {
- for (Method m: ((Class) c).getDeclaredMethods())
- if (m.getName().equals("deserialize"))
- newtypes = m.getGenericParameterTypes();
- }
- else
- for (Method m: ((Class) ((ParameterizedType) c).getRawType()).getDeclaredMethods())
- if (m.getName().equals("deserialize"))
- newtypes = m.getGenericParameterTypes();
-
- if (null == newtypes) throw new DBusException(_("Serializable classes must implement a deserialize method"));
-
- String[] sigs = new String[newtypes.length];
- for (int j = 0; j < sigs.length; j++) {
- String[] ss = recursiveGetDBusType(newtypes[j], false, level+1);
- if (1 != ss.length) throw new DBusException(_("Serializable classes must serialize to native DBus types"));
- sigs[j] = ss[0];
- }
- return sigs;
} else {
throw new DBusException(_("Exporting non-exportable type ")+c);
}
@@ -553,6 +555,7 @@ public class Marshalling
return parameters;
}
+ @SuppressWarnings("unchecked")
static Object[] deSerializeParameters(Object[] parameters, Type[] types, AbstractConnection conn) throws Exception
{
if (Debug.debug) Debug.print(Debug.VERBOSE, "Deserializing from "+Arrays.deepToString(parameters)+" to "+Arrays.deepToString(types));
@@ -570,16 +573,23 @@ public class Marshalling
}
if (null == parameters[i]) continue;
- if (types[i] instanceof Class &&
- DBusSerializable.class.isAssignableFrom((Class) types[i])) {
- for (Method m: ((Class) types[i]).getDeclaredMethods())
+ if ((types[i] instanceof Class &&
+ DBusSerializable.class.isAssignableFrom((Class<? extends Object>) types[i])) ||
+ (types[i] instanceof ParameterizedType &&
+ DBusSerializable.class.isAssignableFrom((Class<? extends Object>) ((ParameterizedType) types[i]).getRawType()))) {
+ Class<? extends DBusSerializable> dsc;
+ if (types[i] instanceof Class)
+ dsc = (Class<? extends DBusSerializable>) types[i];
+ else
+ dsc = (Class<? extends DBusSerializable>) ((ParameterizedType) types[i]).getRawType();
+ for (Method m: dsc.getDeclaredMethods())
if (m.getName().equals("deserialize")) {
Type[] newtypes = m.getGenericParameterTypes();
try {
Object[] sub = new Object[newtypes.length];
System.arraycopy(parameters, i, sub, 0, newtypes.length);
sub = deSerializeParameters(sub, newtypes, conn);
- DBusSerializable sz = (DBusSerializable) ((Class) types[i]).newInstance();
+ DBusSerializable sz = dsc.newInstance();
m.invoke(sz, sub);
Object[] compress = new Object[parameters.length - newtypes.length + 1];
System.arraycopy(parameters, 0, compress, 0, i);
diff --git a/org/freedesktop/dbus/Message.java b/org/freedesktop/dbus/Message.java
index 1e3699e..4640630 100644
--- a/org/freedesktop/dbus/Message.java
+++ b/org/freedesktop/dbus/Message.java
@@ -925,7 +925,7 @@ public class Message
ofs[0] = ofssave;
entries.add((Object[]) extractone(sigb, buf, ofs, true));
}
- rv = new DBusMap(entries.toArray(new Object[0][]));
+ rv = new DBusMap<Object, Object>(entries.toArray(new Object[0][]));
break;
default:
if (0 == size) {
diff --git a/org/freedesktop/dbus/MessageWriter.java b/org/freedesktop/dbus/MessageWriter.java
index cfbcbc8..9928d12 100644
--- a/org/freedesktop/dbus/MessageWriter.java
+++ b/org/freedesktop/dbus/MessageWriter.java
@@ -10,7 +10,6 @@
*/
package org.freedesktop.dbus;
-import java.io.BufferedOutputStream;
import java.io.OutputStream;
import java.io.IOException;
diff --git a/org/freedesktop/dbus/MethodReturn.java b/org/freedesktop/dbus/MethodReturn.java
index cab6301..ac3a6fd 100644
--- a/org/freedesktop/dbus/MethodReturn.java
+++ b/org/freedesktop/dbus/MethodReturn.java
@@ -12,7 +12,6 @@ package org.freedesktop.dbus;
import java.util.Vector;
import org.freedesktop.dbus.exceptions.DBusException;
-import org.freedesktop.dbus.exceptions.MessageFormatException;
public class MethodReturn extends Message
{
diff --git a/org/freedesktop/dbus/RemoteInvocationHandler.java b/org/freedesktop/dbus/RemoteInvocationHandler.java
index 597c03f..00e57be 100644
--- a/org/freedesktop/dbus/RemoteInvocationHandler.java
+++ b/org/freedesktop/dbus/RemoteInvocationHandler.java
@@ -12,17 +12,13 @@ package org.freedesktop.dbus;
import static org.freedesktop.dbus.Gettext._;
-import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
-import java.lang.reflect.GenericArrayType;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
import java.text.MessageFormat;
-import java.util.List;
import org.freedesktop.DBus;
import org.freedesktop.dbus.exceptions.DBusException;
@@ -38,7 +34,7 @@ class RemoteInvocationHandler implements InvocationHandler
public static final int CALL_TYPE_CALLBACK = 2;
public static Object convertRV(String sig, Object[] rp, Method m, AbstractConnection conn) throws DBusException
{
- Class c = m.getReturnType();
+ Class<? extends Object> c = m.getReturnType();
if (null == rp) {
if(null == c || Void.TYPE.equals(c)) return null;
@@ -72,7 +68,7 @@ class RemoteInvocationHandler implements InvocationHandler
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 cons = c.getConstructors()[0];
+ Constructor<? extends Object> cons = c.getConstructors()[0];
try {
return cons.newInstance(rp);
} catch (Exception e) {
@@ -81,6 +77,7 @@ class RemoteInvocationHandler implements InvocationHandler
}
}
}
+ @SuppressWarnings("unchecked")
public static Object executeRemoteMethod(RemoteObject ro, Method m, AbstractConnection conn, int syncmethod, CallbackHandler callback, Object... args) throws DBusExecutionException
{
Type[] ts = m.getGenericParameterTypes();
diff --git a/org/freedesktop/dbus/Struct.java b/org/freedesktop/dbus/Struct.java
index 6fd73af..c24d666 100644
--- a/org/freedesktop/dbus/Struct.java
+++ b/org/freedesktop/dbus/Struct.java
@@ -10,12 +10,6 @@
*/
package org.freedesktop.dbus;
-import java.util.HashMap;
-import java.util.Map;
-import java.lang.reflect.Field;
-import java.lang.reflect.Type;
-import org.freedesktop.dbus.Position;
-
/**
* This class should be extended to create Structs.
* Any such class may be sent over DBus to a method which takes a Struct.
diff --git a/org/freedesktop/dbus/Transport.java b/org/freedesktop/dbus/Transport.java
index eceebd8..3a43293 100644
--- a/org/freedesktop/dbus/Transport.java
+++ b/org/freedesktop/dbus/Transport.java
@@ -13,7 +13,6 @@ package org.freedesktop.dbus;
import static org.freedesktop.dbus.Gettext._;
import java.io.BufferedReader;
-import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -705,7 +704,6 @@ public class Transport
return state == AUTHENTICATED;
}
}
- private BusAddress address;
public MessageReader min;
public MessageWriter mout;
public Transport() {}
@@ -744,7 +742,6 @@ public class Transport
public void connect(BusAddress address, int timeout) throws IOException
{
if (Debug.debug) Debug.print(Debug.INFO, "Connecting to "+address);
- this.address = address;
OutputStream out = null;
InputStream in = null;
UnixSocket us = null;
diff --git a/org/freedesktop/dbus/Tuple.java b/org/freedesktop/dbus/Tuple.java
index 60a1aaf..0ab1760 100644
--- a/org/freedesktop/dbus/Tuple.java
+++ b/org/freedesktop/dbus/Tuple.java
@@ -10,12 +10,6 @@
*/
package org.freedesktop.dbus;
-import java.util.HashMap;
-import java.util.Map;
-import java.lang.reflect.Field;
-import java.lang.reflect.Type;
-import org.freedesktop.dbus.Position;
-
/**
* This class should be extended to create Tuples.
* Any such class may be used as the return type for a method
diff --git a/org/freedesktop/dbus/Variant.java b/org/freedesktop/dbus/Variant.java
index c5c9673..03e8cce 100644
--- a/org/freedesktop/dbus/Variant.java
+++ b/org/freedesktop/dbus/Variant.java
@@ -102,10 +102,11 @@ public class Variant<T>
/** Format the Variant as a string. */
public String toString() { return "["+o+"]"; }
/** Compare this Variant with another by comparing contents */
+ @SuppressWarnings("unchecked")
public boolean equals(Object other)
{
if (null == other) return false;
if (!(other instanceof Variant)) return false;
- return this.o.equals(((Variant)other).o);
+ return this.o.equals(((Variant<? extends Object>)other).o);
}
}
diff --git a/org/freedesktop/dbus/bin/CreateInterface.java b/org/freedesktop/dbus/bin/CreateInterface.java
index fe769eb..4b778fa 100644
--- a/org/freedesktop/dbus/bin/CreateInterface.java
+++ b/org/freedesktop/dbus/bin/CreateInterface.java
@@ -38,7 +38,6 @@ import javax.xml.parsers.ParserConfigurationException;
import org.freedesktop.DBus.Introspectable;
import org.freedesktop.dbus.DBusConnection;
-import org.freedesktop.dbus.Marshalling;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
import org.freedesktop.dbus.types.DBusStructType;
@@ -54,11 +53,12 @@ import org.xml.sax.SAXException;
*/
public class CreateInterface
{
+ @SuppressWarnings("unchecked")
private static String collapseType(Type t, Set<String> imports, Map<StructStruct, Type[]> structs, boolean container, boolean fullnames) throws DBusException
{
if (t instanceof ParameterizedType) {
String s;
- Class c = (Class) ((ParameterizedType) t).getRawType();
+ Class<? extends Object> c = (Class<? extends Object>) ((ParameterizedType) t).getRawType();
if (null != structs && t instanceof DBusStructType) {
int num = 1;
String name = "Struct";
@@ -77,7 +77,7 @@ public class CreateInterface
s = s.replaceAll(",$", ">");
return s;
} else if (t instanceof Class) {
- Class c = (Class) t;
+ Class<? extends Object> c = (Class<? extends Object>) t;
if (c.isArray()) {
return collapseType(c.getComponentType(), imports, structs, container, fullnames)+"[]";
} else {
@@ -90,7 +90,7 @@ public class CreateInterface
} else {
try {
Field f = c.getField("TYPE");
- Class d = (Class) f.get(c);
+ Class<? extends Object> d = (Class<? extends Object>) f.get(c);
return d.getSimpleName();
} catch (Exception e) {
return c.getSimpleName();
@@ -103,7 +103,7 @@ public class CreateInterface
{
if (null == dbus || "".equals(dbus)) return "";
Vector<Type> v = new Vector<Type>();
- int c = Marshalling.getJavaType(dbus, v, 1);
+ /* UNNECCESSARY?? int c = Marshalling.getJavaType(dbus, v, 1);*/
Type t = v.get(0);
return collapseType(t, imports, structs, container, fullnames);
}
diff --git a/org/freedesktop/dbus/bin/DBusDaemon.java b/org/freedesktop/dbus/bin/DBusDaemon.java
index 460f031..97444fa 100644
--- a/org/freedesktop/dbus/bin/DBusDaemon.java
+++ b/org/freedesktop/dbus/bin/DBusDaemon.java
@@ -34,7 +34,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
-import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.ServerSocket;
@@ -45,7 +44,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.Queue;
import java.util.Vector;
import cx.ath.matthew.debug.Debug;
@@ -300,6 +298,7 @@ public class DBusDaemon extends Thread
if (Debug.debug) Debug.print(Debug.DEBUG, "exit");
return;
}
+ @SuppressWarnings("unchecked")
private void handleMessage(Connstruct c, Message m) throws DBusException
{
if (Debug.debug) Debug.print(Debug.DEBUG, "enter");
@@ -307,7 +306,7 @@ public class DBusDaemon extends Thread
if (!(m instanceof MethodCall)) return;
Object[] args = m.getParameters();
- Class[] cs = new Class[args.length];
+ Class<? extends Object>[] cs = new Class[args.length];
for (int i = 0; i < cs.length; i++)
cs[i] = args[i].getClass();
diff --git a/org/freedesktop/dbus/bin/StructStruct.java b/org/freedesktop/dbus/bin/StructStruct.java
index 202e8a5..d824d8e 100644
--- a/org/freedesktop/dbus/bin/StructStruct.java
+++ b/org/freedesktop/dbus/bin/StructStruct.java
@@ -14,8 +14,6 @@ import java.lang.reflect.Type;
import java.util.Map;
import java.util.HashMap;
-import org.freedesktop.dbus.exceptions.DBusException;
-
class StructStruct
{
public static Map<StructStruct, Type[]> fillPackages(Map<StructStruct, Type[]> structs, String pack)
diff --git a/org/freedesktop/dbus/exceptions/UnknownTypeCodeException.java b/org/freedesktop/dbus/exceptions/UnknownTypeCodeException.java
index 385df44..354d82c 100644
--- a/org/freedesktop/dbus/exceptions/UnknownTypeCodeException.java
+++ b/org/freedesktop/dbus/exceptions/UnknownTypeCodeException.java
@@ -10,8 +10,6 @@
*/
package org.freedesktop.dbus.exceptions;
-import java.io.IOException;
-
@SuppressWarnings("serial")
public class UnknownTypeCodeException extends DBusException implements NonFatalException
{
diff --git a/org/freedesktop/dbus/test/ProfileStruct.java b/org/freedesktop/dbus/test/ProfileStruct.java
index 10765e7..b8b6b83 100644
--- a/org/freedesktop/dbus/test/ProfileStruct.java
+++ b/org/freedesktop/dbus/test/ProfileStruct.java
@@ -13,7 +13,6 @@ package org.freedesktop.dbus.test;
import org.freedesktop.dbus.Position;
import org.freedesktop.dbus.Struct;
import org.freedesktop.dbus.UInt32;
-import org.freedesktop.dbus.Variant;
public final class ProfileStruct extends Struct
{
diff --git a/org/freedesktop/dbus/test/TestNewInterface.java b/org/freedesktop/dbus/test/TestNewInterface.java
index ffdc640..b0775ce 100644
--- a/org/freedesktop/dbus/test/TestNewInterface.java
+++ b/org/freedesktop/dbus/test/TestNewInterface.java
@@ -11,12 +11,8 @@
package org.freedesktop.dbus.test;
import org.freedesktop.dbus.DBusInterface;
-import org.freedesktop.dbus.UInt16;
import org.freedesktop.DBus.Description;
-import org.freedesktop.DBus.Method;
-import java.util.Map;
-import java.util.List;
/**
* A sample remote interface which exports one method.
*/
diff --git a/org/freedesktop/dbus/test/TestRemoteInterface2.java b/org/freedesktop/dbus/test/TestRemoteInterface2.java
index 0a03a2c..fb22065 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 s, int i);
+ public void 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)")
@@ -48,7 +48,7 @@ public interface TestRemoteInterface2 extends DBusInterface
@Description("Get new objects as object paths.")
public TestNewInterface getNew();
@Description("Test Complex Variants")
- public void complexv(Variant v);
+ public void complexv(Variant<? extends Object> v);
@Description("Test Introspect on a different interface")
public String Introspect();
}
diff --git a/org/freedesktop/dbus/test/TestSerializable.java b/org/freedesktop/dbus/test/TestSerializable.java
index d3971b5..2da4f83 100644
--- a/org/freedesktop/dbus/test/TestSerializable.java
+++ b/org/freedesktop/dbus/test/TestSerializable.java
@@ -10,14 +10,10 @@
*/
package org.freedesktop.dbus.test;
-import java.lang.reflect.Type;
-
import java.util.List;
import java.util.Vector;
-import org.freedesktop.dbus.DBusConnection;
import org.freedesktop.dbus.DBusSerializable;
-import org.freedesktop.dbus.Marshalling;
import org.freedesktop.dbus.exceptions.DBusException;
public class TestSerializable<A> implements DBusSerializable
diff --git a/org/freedesktop/dbus/test/TestSignalInterface.java b/org/freedesktop/dbus/test/TestSignalInterface.java
index 80a11ed..ab0a951 100644
--- a/org/freedesktop/dbus/test/TestSignalInterface.java
+++ b/org/freedesktop/dbus/test/TestSignalInterface.java
@@ -15,7 +15,6 @@ import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.DBusMemberName;
import org.freedesktop.dbus.DBusSignal;
import org.freedesktop.dbus.UInt32;
-import org.freedesktop.dbus.Variant;
import org.freedesktop.dbus.exceptions.DBusException;
import java.util.List;
diff --git a/org/freedesktop/dbus/test/TestStruct.java b/org/freedesktop/dbus/test/TestStruct.java
index 80fa360..033c5e0 100644
--- a/org/freedesktop/dbus/test/TestStruct.java
+++ b/org/freedesktop/dbus/test/TestStruct.java
@@ -22,8 +22,8 @@ public final class TestStruct extends Struct
@Position(1)
public final UInt32 b;
@Position(2)
- public final Variant c;
- public TestStruct(String a, UInt32 b, Variant c)
+ public final Variant<? extends Object> c;
+ public TestStruct(String a, UInt32 b, Variant<? extends Object> c)
{
this.a = a;
this.b = b;
diff --git a/org/freedesktop/dbus/test/TestStruct2.java b/org/freedesktop/dbus/test/TestStruct2.java
index 1de32ab..0b307d7 100644
--- a/org/freedesktop/dbus/test/TestStruct2.java
+++ b/org/freedesktop/dbus/test/TestStruct2.java
@@ -22,8 +22,8 @@ public final class TestStruct2 extends Struct
@Position(0)
public final List<String> a;
@Position(1)
- public final Variant b;
- public TestStruct2(List<String> a, Variant b) throws DBusException
+ public final Variant<? extends Object> b;
+ public TestStruct2(List<String> a, Variant<? extends Object> b) throws DBusException
{
this.a = a;
this.b = b;
diff --git a/org/freedesktop/dbus/test/TestStruct3.java b/org/freedesktop/dbus/test/TestStruct3.java
index 8b9d502..c89dc67 100644
--- a/org/freedesktop/dbus/test/TestStruct3.java
+++ b/org/freedesktop/dbus/test/TestStruct3.java
@@ -12,7 +12,6 @@ package org.freedesktop.dbus.test;
import org.freedesktop.dbus.Position;
import org.freedesktop.dbus.Struct;
-import org.freedesktop.dbus.Variant;
import org.freedesktop.dbus.exceptions.DBusException;
import java.util.List;
diff --git a/org/freedesktop/dbus/test/cross_test_client.java b/org/freedesktop/dbus/test/cross_test_client.java
index a8f10a8..4093b9c 100644
--- a/org/freedesktop/dbus/test/cross_test_client.java
+++ b/org/freedesktop/dbus/test/cross_test_client.java
@@ -26,7 +26,6 @@ import java.util.TreeSet;
import java.util.Vector;
import org.freedesktop.DBus;
-import org.freedesktop.dbus.DBusCallInfo;
import org.freedesktop.dbus.DBusConnection;
import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.DBusSigHandler;
@@ -37,7 +36,6 @@ import org.freedesktop.dbus.UInt64;
import org.freedesktop.dbus.Variant;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
-import org.freedesktop.dbus.types.DBusListType;
import org.freedesktop.dbus.types.DBusMapType;
import cx.ath.matthew.debug.Debug;
@@ -93,7 +91,8 @@ public class cross_test_client implements DBus.Binding.TestClient, DBusSigHandle
}
reasons.add(reason);
}
- public static void test(Class iface, Object proxy, String method, Object rv, Object... parameters)
+ @SuppressWarnings("unchecked")
+ public static void test(Class<? extends DBusInterface> iface, Object proxy, String method, Object rv, Object... parameters)
{
try {
Method[] ms = iface.getMethods();
@@ -116,14 +115,14 @@ public class cross_test_client implements DBus.Binding.TestClient, DBusSigHandle
compareArray(iface.getName()+"."+method, rv,o);
} else if (rv instanceof Map) {
if (o instanceof Map) {
- Map a = (Map) o;
- Map b = (Map) rv;
+ Map<Object,Object> a = (Map<Object,Object>) o;
+ Map<Object,Object> b = (Map<Object,Object>) rv;
if (a.keySet().size() != b.keySet().size()) {
fail(iface.getName()+"."+method, msg);
} else for (Object k: a.keySet())
if (a.get(k) instanceof List) {
if (b.get(k) instanceof List)
- if (setCompareLists((List) a.get(k), (List) b.get(k)))
+ if (setCompareLists((List<Object>) a.get(k), (List<Object>) b.get(k)))
;
else
fail(iface.getName()+"."+method, msg);
@@ -153,6 +152,7 @@ public class cross_test_client implements DBus.Binding.TestClient, DBusSigHandle
fail(iface.getName()+"."+method, "Error occurred during execution: "+e.getClass().getName()+" "+e.getMessage());
}
}
+ @SuppressWarnings("unchecked")
public static String collapseArray(Object array)
{
if (null == array) return "null";
@@ -164,19 +164,19 @@ public class cross_test_client implements DBus.Binding.TestClient, DBusSigHandle
return s;
} else if (array instanceof List) {
String s = "{ ";
- for (Object o: (List) array)
+ for (Object o: (List<Object>) array)
s += collapseArray(o)+",";
s = s.replaceAll(".$"," }");
return s;
} else if (array instanceof Map) {
String s = "{ ";
- for (Object o: ((Map) array).keySet())
- s += collapseArray(o)+" => "+collapseArray(((Map) array).get(o))+",";
+ for (Object o: ((Map<Object,Object>) array).keySet())
+ s += collapseArray(o)+" => "+collapseArray(((Map<Object,Object>) array).get(o))+",";
s = s.replaceAll(".$"," }");
return s;
} else return array.toString();
}
- public static boolean setCompareLists(List a, List b)
+ public static <T> boolean setCompareLists(List<T> a, List<T> b)
{
if (a.size() != b.size()) return false;
for (Object v: a)
@@ -184,15 +184,15 @@ public class cross_test_client implements DBus.Binding.TestClient, DBusSigHandle
return true;
}
@SuppressWarnings("unchecked")
- public static List<Variant> PrimitizeRecurse(Object a, Type t)
+ public static List<Variant<Object>> PrimitizeRecurse(Object a, Type t)
{
- List<Variant> vs = new Vector<Variant>();
+ List<Variant<Object>> vs = new Vector<Variant<Object>>();
if (t instanceof ParameterizedType) {
- Class c = (Class) ((ParameterizedType) t).getRawType();
+ Class<Object> c = (Class<Object>) ((ParameterizedType) t).getRawType();
if (List.class.isAssignableFrom(c)) {
Object os;
if (a instanceof List)
- os = ((List) a).toArray();
+ os = ((List<Object>) a).toArray();
else
os = a;
Type[] ts = ((ParameterizedType) t).getActualTypeArguments();
@@ -228,7 +228,7 @@ public class cross_test_client implements DBus.Binding.TestClient, DBusSigHandle
}
@SuppressWarnings("unchecked")
- public static List<Variant> Primitize(Variant a)
+ public static List<Variant<Object>> Primitize(Variant<Object> a)
{
return PrimitizeRecurse(a.getValue(), a.getType());
}
@@ -236,9 +236,9 @@ public class cross_test_client implements DBus.Binding.TestClient, DBusSigHandle
@SuppressWarnings("unchecked")
public static void primitizeTest(DBus.Binding.Tests tests, Object input)
{
- Variant in = new Variant(input);
- List<Variant> vs = Primitize(in);
- List<Variant> res;
+ Variant<Object> in = new Variant<Object>(input);
+ List<Variant<Object>> vs = Primitize(in);
+ List<Variant<Object>> res;
try {
@@ -433,7 +433,7 @@ public class cross_test_client implements DBus.Binding.TestClient, DBusSigHandle
test(DBus.Binding.Tests.class, tests, "Exit", null);
}
- public static void testArray(Class iface, Object proxy, String method, Class arrayType, Object content)
+ public static void testArray(Class<? extends DBusInterface> iface, Object proxy, String method, Class<? extends Object> arrayType, Object content)
{
Object array = Array.newInstance(arrayType, 0);
test(iface, proxy, method, array, array);
diff --git a/org/freedesktop/dbus/test/cross_test_server.java b/org/freedesktop/dbus/test/cross_test_server.java
index d7e0f3c..d8086e6 100644
--- a/org/freedesktop/dbus/test/cross_test_server.java
+++ b/org/freedesktop/dbus/test/cross_test_server.java
@@ -10,8 +10,6 @@
*/
package org.freedesktop.dbus.test;
-import java.lang.reflect.Type;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -20,11 +18,8 @@ import java.util.Set;
import java.util.Vector;
import org.freedesktop.DBus;
-import org.freedesktop.dbus.DBusCallInfo;
import org.freedesktop.dbus.DBusConnection;
-import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.DBusSigHandler;
-import org.freedesktop.dbus.Struct;
import org.freedesktop.dbus.UInt16;
import org.freedesktop.dbus.UInt32;
import org.freedesktop.dbus.UInt64;
@@ -79,7 +74,7 @@ public class cross_test_server implements DBus.Binding.Tests, DBus.Binding.Singl
public boolean isRemote() { return false; }
@SuppressWarnings("unchecked")
@DBus.Description("Returns whatever it is passed")
- public Variant Identity(Variant input)
+ public <T> Variant<T> Identity(Variant<T> input)
{
done.add("org.freedesktop.DBus.Binding.Tests.Identity");
notdone.remove("org.freedesktop.DBus.Binding.Tests.Identity");
@@ -156,7 +151,7 @@ public class cross_test_server implements DBus.Binding.Tests, DBus.Binding.Singl
return input;
}
@DBus.Description("Returns whatever it is passed")
- public Variant[] IdentityArray(Variant[] input)
+ public <T> Variant<T>[] IdentityArray(Variant<T>[] input)
{
done.add("org.freedesktop.DBus.Binding.Tests.IdentityArray");
notdone.remove("org.freedesktop.DBus.Binding.Tests.IdentityArray");
@@ -248,7 +243,6 @@ public class cross_test_server implements DBus.Binding.Tests, DBus.Binding.Singl
notdone.remove("org.freedesktop.DBus.Binding.SingleTests.Sum");
int sum = 0;
for (byte b: a) sum += (b < 0 ? b+256 : b);
- sum = sum;
return new UInt32(sum % (UInt32.MAX_VALUE+1));
}
@DBus.Description("Given a map of A => B, should return a map of B => a list of all the As which mapped to B")
@@ -277,7 +271,7 @@ public class cross_test_server implements DBus.Binding.Tests, DBus.Binding.Singl
}
@DBus.Description("Given any compound type as a variant, return all the primitive types recursively contained within as an array of variants")
@SuppressWarnings("unchecked")
- public List<Variant> Primitize(Variant a)
+ public List<Variant<Object>> Primitize(Variant<Object> a)
{
done.add("org.freedesktop.DBus.Binding.Tests.Primitize");
notdone.remove("org.freedesktop.DBus.Binding.Tests.Primitize");
diff --git a/org/freedesktop/dbus/test/profile.java b/org/freedesktop/dbus/test/profile.java
index 40de278..4edabf8 100644
--- a/org/freedesktop/dbus/test/profile.java
+++ b/org/freedesktop/dbus/test/profile.java
@@ -17,10 +17,8 @@ import java.util.Vector;
import org.freedesktop.DBus.Peer;
import org.freedesktop.DBus.Introspectable;
import org.freedesktop.dbus.DBusConnection;
-import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.DBusSigHandler;
import org.freedesktop.dbus.UInt32;
-import org.freedesktop.dbus.exceptions.DBusException;
class ProfileHandler implements DBusSigHandler<Profiler.ProfileSignal>
{
diff --git a/org/freedesktop/dbus/test/test.java b/org/freedesktop/dbus/test/test.java
index 64a062f..fb3f1b7 100644
--- a/org/freedesktop/dbus/test/test.java
+++ b/org/freedesktop/dbus/test/test.java
@@ -36,7 +36,6 @@ import org.freedesktop.dbus.UInt64;
import org.freedesktop.dbus.Variant;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
-import org.freedesktop.dbus.types.DBusListType;
import org.freedesktop.DBus;
import org.freedesktop.DBus.Error.MatchRuleInvalid;
@@ -218,7 +217,7 @@ class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignal
{
throw new TestException("test");
}
- public void testSerializable(byte b, TestSerializable s, int i)
+ public void testSerializable(byte b, TestSerializable<String> s, int i)
{
System.out.println("Recieving TestSerializable: "+s);
if ( b != 12
@@ -226,9 +225,9 @@ class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignal
|| !(s.getInt() == 1)
|| !(s.getString().equals("woo"))
|| !(s.getVector().size() == 3)
- || !((Integer) s.getVector().get(0) == 1)
- || !((Integer) s.getVector().get(1) == 2)
- || !((Integer) s.getVector().get(2) == 3) )
+ || !(s.getVector().get(0) == 1)
+ || !(s.getVector().get(1) == 2)
+ || !(s.getVector().get(2) == 3) )
test.fail("Error in recieving custom synchronisation");
}
public String recursionTest()
@@ -283,12 +282,13 @@ class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignal
|| ! Integer.class.equals(((ParameterizedType) s[1]).getActualTypeArguments()[1]))
test.fail("Didn't send types correctly");
}
- public void complexv(Variant v)
+ @SuppressWarnings("unchecked")
+ public void complexv(Variant<? extends Object> v)
{
if (!"a{ss}".equals(v.getSig())
|| ! (v.getValue() instanceof Map)
- || ((Map) v.getValue()).size() != 1
- || !"moo".equals(((Map) v.getValue()).get("cow")))
+ || ((Map<Object,Object>) v.getValue()).size() != 1
+ || !"moo".equals(((Map<Object,Object>) v.getValue()).get("cow")))
test.fail("Didn't send variant correctly");
}
}
@@ -316,10 +316,10 @@ class signalhandler implements DBusSigHandler<TestSignalInterface.TestSignal>
/**
* Untyped signal handler
*/
-class arraysignalhandler implements DBusSigHandler
+class arraysignalhandler implements DBusSigHandler<TestSignalInterface.TestArraySignal>
{
/** Handling a signal */
- public void handle(DBusSignal s)
+ public void handle(TestSignalInterface.TestArraySignal t)
{
try {
if (false == test.done2) {
@@ -327,7 +327,6 @@ class arraysignalhandler implements DBusSigHandler
} else {
test.fail("SignalHandler 2 has been run too many times");
}
- TestSignalInterface.TestArraySignal t = (TestSignalInterface.TestArraySignal) s;
System.out.println("SignalHandler 2 Running");
if (t.v.size() != 1) test.fail("Incorrect TestArraySignal array length: should be 1, actually "+t.v.size());
System.out.println("Got a test array signal with Parameters: ");
@@ -370,10 +369,10 @@ class objectsignalhandler implements DBusSigHandler<TestSignalInterface.TestObje
/**
* handler which should never be called
*/
-class badarraysignalhandler implements DBusSigHandler
+class badarraysignalhandler<T extends DBusSignal> implements DBusSigHandler<T>
{
/** Handling a signal */
- public void handle(DBusSignal s)
+ public void handle(T s)
{
test.fail("This signal handler shouldn't be called");
}
@@ -436,7 +435,7 @@ public class test
String source = dbus.GetNameOwner("foo.bar.Test");
clientconn.addSigHandler(TestSignalInterface.TestArraySignal.class, source, peer, new arraysignalhandler());
clientconn.addSigHandler(TestSignalInterface.TestObjectSignal.class, new objectsignalhandler());
- badarraysignalhandler bash = new badarraysignalhandler();
+ badarraysignalhandler<TestSignalInterface.TestSignal> bash = new badarraysignalhandler<TestSignalInterface.TestSignal>();
clientconn.addSigHandler(TestSignalInterface.TestSignal.class, bash);
clientconn.removeSigHandler(TestSignalInterface.TestSignal.class, bash);
System.out.println("done");
diff --git a/org/freedesktop/dbus/test/test_low_level.java b/org/freedesktop/dbus/test/test_low_level.java
index 06ac156..d81587f 100644
--- a/org/freedesktop/dbus/test/test_low_level.java
+++ b/org/freedesktop/dbus/test/test_low_level.java
@@ -10,7 +10,6 @@
*/
package org.freedesktop.dbus.test;
import cx.ath.matthew.debug.Debug;
-import cx.ath.matthew.utils.Hexdump;
import org.freedesktop.dbus.BusAddress;
import org.freedesktop.dbus.DBusSignal;
import org.freedesktop.dbus.Message;
diff --git a/org/freedesktop/dbus/test/test_p2p_server.java b/org/freedesktop/dbus/test/test_p2p_server.java
index cea5ac3..6ba7af2 100644
--- a/org/freedesktop/dbus/test/test_p2p_server.java
+++ b/org/freedesktop/dbus/test/test_p2p_server.java
@@ -19,7 +19,6 @@ import java.util.Map;
import org.freedesktop.dbus.DirectConnection;
import org.freedesktop.dbus.Path;
-import org.freedesktop.dbus.Transport;
import org.freedesktop.dbus.UInt16;
public class test_p2p_server implements TestRemoteInterface