parameters[i] = new Variant(parameters[i]);
parameters[i] = new Variant<Object>(parameters[i]);
   public static Object[] convertParameters(Object[] parameters, Type[] types) throws DBusException   {      if (null == parameters) return null;      for (int i = 0; i < parameters.length; i++) {         if (types[i] instanceof Class &&               DBusSerializable.class.isAssignableFrom((Class) types[i])) {            for (Method m: ((Class) types[i]).getDeclaredMethods())                if (m.getName().equals("deserialize")) {                  Type[] newtypes = m.getGenericParameterTypes();                  Type[] expand = new Type[types.length + newtypes.length - 1];                  System.arraycopy(types, 0, expand, 0, i);                   System.arraycopy(newtypes, 0, expand, i, newtypes.length);                   System.arraycopy(types, i+1, expand, i+newtypes.length, types.length-i-1);                   types = expand;               }         }                  // its an unwrapped variant, wrap it         if (types[i] instanceof TypeVariable &&               !(parameters[i] instanceof Variant)) {            parameters[i] = new Variant(parameters[i]);         }                  // its something parameterised         else if (types[i] instanceof ParameterizedType) {            ParameterizedType p = (ParameterizedType) types[i];            Class r = (Class) p.getRawType();            // its a list, wrap it in our typed container class            if (List.class.isAssignableFrom(r)) {               parameters[i] = new ListContainer((List) parameters[i], p);            }            // its a map, wrap it in our typed container class            else if (Map.class.isAssignableFrom(r)) {               parameters[i] = new MapContainer((Map) parameters[i], p);            }            // its a struct, recurse over it            else if (Struct.class.isAssignableFrom(r)) {               Constructor con = r.getDeclaredConstructors()[0];               Field[] fs = r.getDeclaredFields();               Type[] ts = new Type[fs.length];               for (Field f : fs) {                  Position pos = f.getAnnotation(Position.class);                  if (null == pos) continue;                  ts[pos.value()] = f.getGenericType();               }               Object[] oldparams = ((Struct) parameters[i]).getParameters();               Object[] newparams = convertParameters(oldparams, ts);               try {                  parameters[i] = con.newInstance(newparams);               } catch (Exception e) {                  throw new DBusException("Failure in serializing parameters: "+e.getMessage());               }            }         }         else if (types[i] instanceof GenericArrayType &&               ! (parameters[i] instanceof Object[]))            parameters[i] = ArrayFrob.wrap(parameters[i]);         else if (types[i] instanceof Class &&               ((Class) types[i]).isArray() &&               ! (parameters[i] instanceof Object[]))            parameters[i] = ArrayFrob.wrap(parameters[i]);               }      return parameters;   }