Creates a new instance of a class.

@param className
Fully-qualified class name
@param arguments
Arguments for constructor
@return A new instance of given class or {@code null} if creation failed
515051
@SuppressWarnings("unchecked")
	private T createInstance(final String className, final Object... arguments) {
		try {
			Class<?> implementation = Class.forName(className, false, classLoader);
			if (service.isAssignableFrom(implementation)) {
				return (T) implementation.getDeclaredConstructor(argumentTypes).newInstance(arguments);
			} else {
				InternalLogger.log(Level.ERROR, "Class '" + className + "' does not implement servcie interface '" + service + "'");
			}
		} catch (ClassNotFoundException ex) {
			InternalLogger.log(Level.ERROR, "Service implementation '" + className + "' not found");
		} catch (NoSuchMethodException ex) {
			InternalLogger.log(Level.ERROR, "Service implementation '" + className + "' has no matching constructor");
		} catch (InstantiationException ex) {
			InternalLogger.log(Level.ERROR, "Service implementation '" + className + "' is not instantiable");
		} catch (IllegalAccessException ex) {
			InternalLogger.log(Level.ERROR, "Constructor of service implementation '" + className + "' is not accessible");
		} catch (IllegalArgumentException ex) {
			InternalLogger.log(Level.ERROR, "Illegal arguments for constructor of service implementation '" + className + "'");
		} catch (InvocationTargetException ex) {
			InternalLogger.log(Level.ERROR, ex.getTargetException(), "Failed creating service implementation '" + className + "'");
		}

		return null;
	}
763639
public function makeInstance($className)
    {
        // class reflection
        $reflection = new ReflectionClass($className);
        // get the class constructor
        $constructor = $reflection->getConstructor();

        // if there is no constructor, just create and
        // return a new instance
        if (!$constructor) {
            return $reflection->newInstance();
        }

        // created and returns the new instance passing the
        // resolved parameters
        return $reflection->newInstanceArgs($this->resolveParameters($constructor->getParameters(), []));
    }
694716
public static <T> T newInstance(Class<T> clazz) throws ClassInstantiationException {
        if (clazz == null) {
            return null;
        }

        try {
            return clazz.newInstance();
        } catch (Exception e) {
            throw new ClassInstantiationException("Failed to instantiate class: " + clazz.getName(), e);
        }
    }
1136324
@Nonnull
    public BugInstance addClass(@SlashedClassName(when = When.UNKNOWN)  String className) {
        ClassAnnotation classAnnotation = new ClassAnnotation(ClassName.toDottedClassName(className));
        add(classAnnotation);
        return this;
    }
556315
public static Object buildObjectInstance(String classname, Object[] params) {
		Object rets = null;

		Class<?>[] paramTypes = new Class[params.length];
		for (int x = 0; x < params.length; x++) {
			paramTypes[x] = params[x].getClass();
		}

		try {
			Class<?> clazz = getClass(classname);
			rets = clazz.getConstructor(paramTypes).newInstance(params);

		} catch (Exception e) {
			throw new BundlingProcessException(e.getMessage() + " [The custom class " + classname
					+ " could not be instantiated, check wether it is available on the classpath and"
					+ " verify that it has a zero-arg constructor].\n" + " The specific error message is: "
					+ e.getClass().getName() + ":" + e.getMessage(), e);
		}
		return rets;
	}
1200002
public static <T> T newInstance(Class<T> clazz, Object... params) throws UtilException {
		if (ArrayUtil.isEmpty(params)) {
			final Constructor<T> constructor = getConstructor(clazz);
			try {
				return constructor.newInstance();
			} catch (Exception e) {
				throw new UtilException(e, "Instance class [{}] error!", clazz);
			}
		}

		final Class<?>[] paramTypes = ClassUtil.getClasses(params);
		final Constructor<T> constructor = getConstructor(clazz, paramTypes);
		if (null == constructor) {
			throw new UtilException("No Constructor matched for parameter types: [{}]", new Object[] { paramTypes });
		}
		try {
			return constructor.newInstance(params);
		} catch (Exception e) {
			throw new UtilException(e, "Instance class [{}] error!", clazz);
		}
	}
72150
@SuppressWarnings("unchecked")
        public static <T> ClassSup<T> cls(String clsName) {
                try {
                        return mapper.get(clsName, () -> (ClassSup<T>) cls(Class.forName(clsName)));
                } catch (Exception e) {
                        throw $(e);
                }
        }
66385
public final SgClass get(final String className) {
        if (className == null) {
            throw new IllegalArgumentException("The argument 'className' cannot be null!");
        }
        return cache.get(className);
    }
305461
public static <T> T newInstance(String className, SiteConfig config) {
        return newInstance(className, null, null, config);
    }
484770
public Collection<T> createAll(final Object... arguments) {
		Collection<T> instances = new ArrayList<T>(classes.size());

		for (String className : classes) {
			T instance = createInstance(className, arguments);
			if (instance != null) {
				instances.add(instance);
			}
		}

		return instances;
	}
1358362
public synchronized JavaClassModel create(String qualifiedName)
    {
        // if a phantom exists, just convert it
        PhantomJavaClassModel phantom = new GraphService<>(getGraphContext(), PhantomJavaClassModel.class).getUniqueByProperty(
                    JavaClassModel.QUALIFIED_NAME, qualifiedName);
        if (phantom != null)
        {
            GraphService.removeTypeFromModel(getGraphContext(), phantom, PhantomJavaClassModel.class);
            return phantom;
        }
        JavaClassModel javaClassModel = super.create();
        setPropertiesFromName(javaClassModel, qualifiedName);
        return javaClassModel;
    }
699958
public static Object createInstance(String className) {
    Object retv = null;
    try {
      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      Class<?> theFilterClass = Class.forName(className, true, classLoader);
      Constructor meth = theFilterClass.getDeclaredConstructor(argArray);
      meth.setAccessible(true);
      retv = meth.newInstance();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return retv;
  }
497311
public static void instanceOf(final Object arg, final Class<?> clazz, final String name) {
        
        if(arg == null) {
            throw new IllegalArgumentException(String.format("%s should not be null.", name));
        }
        
        if(!clazz.isAssignableFrom(arg.getClass())) {
            throw new IllegalArgumentException(String.format("%s should not be class with '%s'.", name, clazz.getName()));
        }
        
    }
174107
public static <T> T newInstance(final Class<T> klazz) {
    try {
      return klazz.getConstructor().newInstance();
    } catch (Exception ex) {
      throw new Error(String.format("Can't create instance of %s for error %s", klazz.getCanonicalName(), ex.getMessage()), ex);
    }
  }
637029
public static Object newInstance(String name) {
        try {
            return forName(name).newInstance();
        } catch (InstantiationException e) {
            throw new IllegalStateException(e.getMessage(), e);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
263890
public static Object instantiateObject(String className,
                                           ClassLoader classLoader) {
        Object object;
        try {
            object = loadClass(className, classLoader).newInstance();
        } catch ( Throwable e ) {
            throw new RuntimeException( "Unable to instantiate object for class '" + className + "'",
                                        e );
        }
        return object;
    }
791578
@SuppressWarnings("all")
	protected Object newInstance(String className) {
		log.debug("Loading class: {}", className);
		Object instance = null;
		Class<?> clazz = null;
		if ("".equals(className) || className == null)
			return instance;
		try {
			// check for special DS class aliases
			if (className.length() == 3) {
				className = classAliases.get(className);
			}
			if (className.startsWith("flex.")) {
				// Use Red5 compatibility class instead
				className = "org.red5.compatibility." + className;
				log.debug("Modified classname: {}", className);
			}
			if (!classAllowed(className)) {
				log.error("Class creation is not allowed {}", className);
			} else {
				clazz = Thread.currentThread().getContextClassLoader()
						.loadClass(className);
				instance = clazz.newInstance();
			}
		} catch (InstantiationException iex) {
			try {
				// check for default ctor
				clazz.getConstructor(null);
				log.error("Error loading class: {}", className);
			} catch (NoSuchMethodException nse) {
				log.error(
						"Error loading class: {}; this can be resolved by adding a default constructor to your class",
						className);
			}
			log.debug("Exception was: {}", iex);
		} catch (Exception ex) {
			log.error("Error loading class: {}", className);
			log.debug("Exception was: {}", ex);
		}
		return instance;
	}