code: public static <T> T createInstance(Class<T> cls, Object... args) {
          Class<?>[] argTypes = new Class<?>[args.length];
          for (int i = 0; i < args.length; i++) {
              argTypes[i] = args[i].getClass();
          }
          return createInstance(cls, args, argTypes);
      }
docs: Method that can be called to try to create an instantiate of
  specified type.
  
  @param <T> the generic type
  @param cls the class to check
  @param args the arguments
  @return an instantiated object
  @throws IllegalArgumentException if instantiation fails for any reason;
  except for cases where constructor throws an unchecked exception
  (which will be passed as is)