code: private static Object[] toObjectArray(Object primitiveArray) {
          if (primitiveArray == null) {
              throw new NullPointerException();
          }
          
          if (primitiveArray instanceof Object[]) {
              return (Object[]) primitiveArray;
          }
  
          if (primitiveArray instanceof Collection) {
              return ((Collection) primitiveArray).toArray();
          }
            
          Class clazz = primitiveArray.getClass();
          if (!clazz.isArray()) {
              return null;
          }
  
          int length = Array.getLength(primitiveArray);
          Object[] array = new Object[length];
          for (int i = 0; i < length; i++) {
              array[i] = Array.get(primitiveArray, i);
          }
  
          return array;
      }
docs: Convert an array of primitives to an array of boxed objects.
  @param primitiveArray object containing the primitive values
  @return an Object array, or null if the incoming value is not
  in fact an array at all.