Creates an instance of the supplied class.
320665
protected Object createInstance(String classname) {

        // get the classloader to use
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader == null) {
            classLoader = this.getClass().getClassLoader();
        }

        // create an instance of the class using the default constructor
        try {

            return classLoader.loadClass(classname).newInstance();

        } catch (InstantiationException e) {
            throw new IllegalStateException(e);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        } catch (ClassNotFoundException e) {
            throw new IllegalStateException(e);
        }

    }
1211428
public static Object newInstance(String className) throws InstantiationException,
                                                              IllegalAccessException,
                                                              ClassNotFoundException
    {
        return newInstance(getClass(className));
    }
901981
public static <T> T newInstance(String className, Object... initargs) 
	throws SetupException
	{
		return newInstance(toClass(className),initargs);		
	}
1271844
public static <T> T createInstance(Class<T> pClass, Object... pParams)
            throws InvocationTargetException {
        T value;

        try {
            // Create param and argument arrays
            Class[] paramTypes = null;
            if (pParams != null && pParams.length > 0) {
                paramTypes = new Class[pParams.length];
                for (int i = 0; i < pParams.length; i++) {
                    paramTypes[i] = pParams[i].getClass();
                }
            }

            // Get constructor
            Constructor<T> constructor = pClass.getConstructor(paramTypes);

            // Invoke and create instance
            value = constructor.newInstance(pParams);
        }
        /* All this to let InvocationTargetException pass on */
        catch (NoSuchMethodException nsme) {
            return null;
        }
        catch (IllegalAccessException iae) {
            return null;
        }
        catch (IllegalArgumentException iarge) {
            return null;
        }
        catch (InstantiationException ie) {
            return null;
        }
        catch (ExceptionInInitializerError err) {
            return null;
        }

        return value;
    }
196948
private Class createClass(String className) throws ClassNotFoundException {
        Class clazz;
        try {
            URLClassLoader classLoader = URLClassLoader.newInstance(new URL[]{root.toURI().toURL()});
            if (log.isDebugEnabled()) {
                log.debug("Classloader URLs:");
                for (URL url : classLoader.getURLs()) {
                    log.debug("  " + url.toString());
                }
            }

            clazz = Class.forName(className, true, classLoader);
            return clazz;

        } catch (MalformedURLException mue) {
            String info = "Could not load the " + description + " object " + className
                    + ". Malformed URL: ";
            info += mue.getMessage();
            throw new ClassNotFoundException(info, mue);

        } catch (ExceptionInInitializerError eiie) {
            String info = "Could not load the " + description + " object " + className
                    + ". Could not initialize static object in server: ";
            info += eiie.getMessage();
            throw new ClassNotFoundException(info, eiie);

        } catch (LinkageError le) {
            String info = "Could not load the " + description + " object " + className
                    + ". This object is depending on a class that has been changed after compilation ";
            info += "or a class that was not found: ";
            info += le.getMessage();
            throw new ClassNotFoundException(info, le);

        } catch (ClassNotFoundException cnfe) {
            String info = "Could not find the " + description + " object " + className + ": ";
            info += cnfe.getMessage();
            throw new ClassNotFoundException(info, cnfe);
        }
    }
39498
def create(cls, this: str, super_: str=u'java/lang/Object') -> 'ClassFile':
        
        cf = ClassFile()
        cf.access_flags.acc_public = True
        cf.access_flags.acc_super = True

        cf.this = cf.constants.create_class(this)
        cf.super_ = cf.constants.create_class(super_)

        return cf
1270435
public static <T> T newInstance(final String className) {
		try {
			return (T) Thread.currentThread().getContextClassLoader().loadClass(className).newInstance();
		} catch (final Exception e) {
			throw new RuntimeException(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;
	}
1217785
public <T> String create(Class<T> clazz) {
        return create(clazz, null, null);
    }
246570
public Object createInstanceQuietly() {
      try {
         return clazz.newInstance();
      } catch (InstantiationException e) {
         log.finest(e);
         return null;
      } catch (IllegalAccessException e) {
         log.finest(e);
         return null;
      }
   }
603506
def _create_class_instance(class_name, _proxy):
    
    try:
        return _class_instance_from_name('turicreate.extensions.' + class_name, _proxy=_proxy)
    except:
        pass
    return _class_instance_from_name(class_name, _proxy=_proxy)
695395
protected T createInstance() {
        try {
            Constructor<T> ctor = clazz.getDeclaredConstructor();
            ctor.setAccessible(true);
            return ctor.newInstance();
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (SecurityException e) {
            throw new RuntimeException(e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        } catch (IllegalArgumentException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        }
    }
1332795
private Object createInstance(Class pClass, Object pParam) {
    Object value;

    try {

      // Create param and argument arrays
      Class[]  param = { pParam.getClass() };
      Object[] arg   = { pParam };

      // Get constructor
      Constructor constructor = pClass.getDeclaredConstructor(param);

      // Invoke and create instance
      value = constructor.newInstance(arg);
    } catch (Exception e) {
      return null;
    }
    return value;
  }
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);
    }
  }
1368713
def p_mp_createInstance(p):
    """"""
    inst = p[1]
    if p.parser.verbose:
        p.parser.log(
            _format("Creating instance of {0!A}.", inst.classname))
    try:
        p.parser.handle.CreateInstance(inst)
    except CIMError as ce:
        if ce.status_code == CIM_ERR_ALREADY_EXISTS:
            if p.parser.verbose:
                p.parser.log(
                    _format("Instance of class {0!A} already exist. "
                            "Modifying...", inst.classname))
            try:
                p.parser.handle.ModifyInstance(inst)
            except CIMError as ce:
                if ce.status_code == CIM_ERR_NOT_SUPPORTED:
                    if p.parser.verbose:
                        p.parser.log(
                            _format("ModifyInstance not supported. "
                                    "Deleting instance of {0!A}: {1}",
                                    inst.classname, inst.path))
                    p.parser.handle.DeleteInstance(inst.path)
                    if p.parser.verbose:
                        p.parser.log(
                            _format("Creating instance of {0!A}.",
                                    inst.classname))
                    p.parser.handle.CreateInstance(inst)
        else:
            ce.file_line = (p.parser.file, p.lexer.lineno)
            raise
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);
        }
    }