code: private static Object[] toObjectArray(Object val){
          if (val instanceof Object[])
              return (Object[])val;
          int arrayLength = java.lang.reflect.Array.getLength(val);
          Object[] outputArray = new Object[arrayLength];
          for(int i = 0; i < arrayLength; ++i){
              outputArray[i] = java.lang.reflect.Array.get(val, i);
          }
          return outputArray;
      }
docs: from http://stackoverflow.com/questions/5606338/cast-primitive-type-array-into-object-array-in-java