if (((Object[]) parameter).length > MAX_ARRAY_LENGTH) throw new DBusException("Array exceeds maximum length of "+MAX_ARRAY_LENGTH);
if (Array.getLength(parameter) > MAX_ARRAY_LENGTH) throw new DBusException("Array exceeds maximum length of "+MAX_ARRAY_LENGTH);
   static Object convertParameter(Object parameter, Type type) throws DBusException   {      // its an unwrapped variant, wrap it      if (type instanceof TypeVariable &&            !(parameter instanceof Variant)) {         parameter = new Variant<Object>(parameter);      }      // its something parameterised      else if (type instanceof ParameterizedType) {         ParameterizedType p = (ParameterizedType) type;         Class r = (Class) p.getRawType();         // its a list, wrap it in our typed container class         if (List.class.isAssignableFrom(r)) {            parameter = new ListContainer((List<Object>) parameter, p);         }         // its a map, wrap it in our typed container class         else if (Map.class.isAssignableFrom(r)) {            parameter = new MapContainer((Map<Object,Object>) parameter, 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) parameter).getParameters();            Object[] newparams = convertParameters(oldparams, ts);            try {               parameter = con.newInstance(newparams);            } catch (Exception e) {               if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();               throw new DBusException("Failure in serializing parameters: "+e.getMessage());            }         }      }      else if (type instanceof GenericArrayType) {         if (((Object[]) parameter).length > MAX_ARRAY_LENGTH) throw new DBusException("Array exceeds maximum length of "+MAX_ARRAY_LENGTH);         Type t = ((GenericArrayType) type).getGenericComponentType();         if (!(t instanceof Class) || !((Class) t).isPrimitive())            parameter = new ListContainer((Object[]) parameter, t);      } else if (type instanceof Class && ((Class) type).isArray()) {         if (Array.getLength(parameter) > MAX_ARRAY_LENGTH) throw new DBusException("Array exceeds maximum length of "+MAX_ARRAY_LENGTH);         if (!((Class) type).getComponentType().isPrimitive())            parameter = new ListContainer((Object[]) parameter, ((Class) type).getComponentType());      }      return parameter;   }