code: public static final <T> T newInstance(Class<T> cls, Object ... initargs) {
          Class<?>[] paramCls = null;
          if (initargs != null) {
              paramCls = new Class[initargs.length];
              for (int i = 0; i < initargs.length; i++) {
                  paramCls[i] = initargs[i].getClass();
              }
          }
          
          try {
              Constructor<T> con = cls.getDeclaredConstructor(paramCls);
              con.setAccessible(true);
              return con.newInstance(initargs);
          } catch (SecurityException e) {
              throw new RuntimeException(e);
          } catch (NoSuchMethodException e) {
              throw new RuntimeException(e);
          } catch (IllegalArgumentException e) {
              throw new RuntimeException(e);
          } catch (InstantiationException e) {
              throw new RuntimeException(e);
          } catch (IllegalAccessException e) {
              throw new RuntimeException(e);
          } catch (InvocationTargetException e) {
              throw new RuntimeException(e);
          }
      }
docs: Creates a new instance of the class <tt>cls</tt> using the constructor
  that matches the classes of the given arguments. This method will
  attempt to use any constructor, regardless of its modifiers.
  @param <T> The type
  @param cls The class
  @param initargs Constructor arguments
  @return a new instance of the class <tt>cls</tt>.