Here you can find the source of newInstance(final Class> clazz, final Object[] parameters)
public static Object newInstance(final Class<?> clazz, final Object[] parameters) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 SAP AG and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from ww w. j av a 2 s . co m * SAP AG - initial API and implementation *******************************************************************************/ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; public class Main { public static Object newInstance(final Class<?> clazz, final Object[] parameters) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { assert clazz != null && parameters != null; return newInstance(clazz, createParameterTypes(parameters), parameters); } public static Object newInstance(final Class<?> clazz, final Class<?>[] parTypes, final Object[] parameters) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { assert clazz != null && parTypes != null && parameters != null; final Constructor<?> constr = clazz.getDeclaredConstructor(parTypes); constr.setAccessible(true); return constr.newInstance(parameters); } private static Class<?>[] createParameterTypes(final Object[] parameters) { assert parameters != null; final List<Class<?>> types = new ArrayList<Class<?>>(); for (final Object object : parameters) { types.add(object.getClass()); } return types.toArray(new Class[types.size()]); } }