Create a new instance of the provided type

@param type the class to create a new instance of
@param parameters the parameters to pass to the constructor
@return the created instance
423740
public static <T> T createInstance(Class<T> type, Object... parameters) {

    // get types for parameters
    Class<?>[] parameterTypes = new Class<?>[parameters.length];
    for (int i = 0; i < parameters.length; i++) {
      Object parameter = parameters[i];
      parameterTypes[i] = parameter.getClass();
    }

    try {
      // create instance
      Constructor<T> constructor = type.getConstructor(parameterTypes);
      return constructor.newInstance(parameters);

    } catch (Exception e) {
      throw new ModelException("Exception while creating an instance of type "+type, e);
    }
  }
457259
public static <T> Instantiator<T> of(Class<T> type) {
        if (Modifier.isAbstract(type.getModifiers())) {
            return new Instantiator<>(giveDynamicSubclass(type));
        }
        return new Instantiator<>(type);
    }
1220065
public function &create($type, $parameters = array())
	{
		$class = $this->get_class($type);

		if (in_array($class, $this->legacy))
		{
			switch ($type)
			{
				case 'locator':
					// Legacy: file, timeout, useragent, file_class, max_checked_feeds, content_type_sniffer_class
					// Specified: file, timeout, useragent, max_checked_feeds
					$replacement = array($this->get_class('file'), $parameters[3], $this->get_class('content_type_sniffer'));
					array_splice($parameters, 3, 1, $replacement);
					break;
			}
		}

		if (!method_exists($class, '__construct'))
		{
			$instance = new $class;
		}
		else
		{
			$reflector = new ReflectionClass($class);
			$instance = $reflector->newInstanceArgs($parameters);
		}

		if (method_exists($instance, 'set_registry'))
		{
			$instance->set_registry($this);
		}
		return $instance;
	}
776860
def create_instance(self, plugin_type, plugin_name, **instance_kwargs):
        """"""
        plugin_type = self._get_plugin_type(plugin_type)
        return plugin_type.create_instance(plugin_name, **instance_kwargs)
1278147
private static ParameterizedType newParameterizedType(final Class<?> base, Type... args) throws Exception {
        return Types.newParameterizedType(base, args);
    }
738699
public Object createNewInstance(Class[] types, Object[] args)
    {
        try
        {
            Object result;
            // create an instance of the target class
            if (types != null)
            {
                result = ClassHelper.newInstance(getClassToServe(), types, args, true);
            }
            else
            {
                result = ClassHelper.newInstance(getClassToServe(), true);
            }
            // if defined in OJB.properties all instances are wrapped by an interceptor
            result = InterceptorFactory.getInstance().createInterceptorFor(result);
            return result;

        }
        catch (InstantiationException e)
        {
            getLogger().error("ConfigurableFactory can't instantiate class " +
                    getClassToServe() + buildArgumentString(types, args), e);
            throw new PersistenceBrokerException(e);
        }
        catch (IllegalAccessException e)
        {
            getLogger().error("ConfigurableFactory can't access constructor for class " +
                    getClassToServe() + buildArgumentString(types, args), e);
            throw new PersistenceBrokerException(e);
        }
        catch (Exception e)
        {
            getLogger().error("ConfigurableFactory instantiation failed for class " +
                    getClassToServe() + buildArgumentString(types, args), e);
            throw new PersistenceBrokerException(e);
        }
    }
719571
public <T> T newInstance (Class<T> type) {
		Registration registration = getRegistration(type);
		ObjectInstantiator instantiator = registration.getInstantiator();
		if (instantiator == null) {
			instantiator = newInstantiator(type);
			registration.setInstantiator(instantiator);
		}
		return (T)instantiator.newInstance();
	}
905271
@Override
	public O withParameters(Configuration parameters) {
		this.parameters = parameters;

		@SuppressWarnings("unchecked")
		O returnType = (O) this;
		return returnType;
	}
192254
public void newObject(TypeDesc type) {
        if (type.isArray()) {
            newObject(type, 1);
        }
        else {
            ConstantInfo info = mCp.addConstantClass(type);
            addCode(1, Opcode.NEW, info);
        }
    }
708805
public static Object newInstance(Class target, Class type, Object arg) throws InstantiationException,
                                                                                  IllegalAccessException,
                                                                                  IllegalArgumentException,
                                                                                  InvocationTargetException,
                                                                                  NoSuchMethodException,
                                                                                  SecurityException
    {
        return newInstance(target, new Class[]{ type }, new Object[]{ arg });
    }
844525
public static AbstractMessage createInstance( byte type )
    {
        switch (type)
        {
            case EMPTY:  return new EmptyMessageImpl();
            case BYTES:  return new BytesMessageImpl();
            case MAP:    return new MapMessageImpl();
            case OBJECT: return new ObjectMessageImpl();
            case STREAM: return new StreamMessageImpl();
            case TEXT:   return new TextMessageImpl();
                
            default:
                throw new IllegalArgumentException("Unsupported message type : "+type);
        }
    }
942042
public Object createNewInstance(Class type, Object arg)
    {
        if (type != null)
            return createNewInstance(new Class[]{type}, new Object[]{arg});
        else
            return createNewInstance((Class[]) null, (Object[]) null);
    }
220808
public static ParameterizedType parameterizedType(Type ownerType, Type rawType,
            Type... typeArguments) {
        return newParameterizedTypeWithOwner(ownerType, rawType, typeArguments);
    }
1332993
public static <T> T newInstance(Type type) {
        try {
            Class<T> clazz = (Class<T>) getClass(type);
            if (clazz == null) {
                return null;
            }
            return clazz.newInstance();
        } catch (Exception e) {
            log.warn("new instance fail :{}", e.getCause().toString());
            throw new NewInstanceException(e.getCause().toString());
        }
    }
389951
@SuppressWarnings("unchecked") // types must agree
  private static List createListObject(ParameterizedType type) {

    Class rawType = (Class) type.getRawType();
    Type[] genericTypes = type.getActualTypeArguments();
    List listObject;

    if (rawType.isInterface()) {
      listObject = new ArrayList(MOCK_LIST_COUNT);
    } else {
      listObject = (List) instantiateObject(rawType);
    }

    for (int i = 0; i < MOCK_LIST_COUNT; i++) {
      listObject.add(generateValue((Class) genericTypes[0]));
    }

    return listObject;
  }
652602
@Trivial
    public static <K> UserConverter<K> newInstance(Type type, Converter<K> converter) {
        return newInstance(type, getPriority(converter), converter);
    }
715508
public static <T> ParameterBuilder<T> create(String name, Class<T> type) {
    return new ParameterBuilder<T>()
        .name(name)
        .type(type);
  }