Creates an instance from a String class name.

@param className
full class name
@param classLoader
the class will be loaded with this ClassLoader
@return new instance of the class
@throws RuntimeException
if class not found or could not be instantiated
327660
public static Object newInstanceFromName(String className, ClassLoader classLoader) {
        try {
            Class<?> clazz = Class.forName(className, true, classLoader);
            return clazz.newInstance();
        } catch (Exception e) {
            String m = "Couldn't create instance from name " + className + " (" + e.getMessage() + ")";
            LOG.error(m, e);
            throw new RuntimeException(m);
        }
    }
416282
public Class loadClass(String name)
    {
        try
        {
            return classLoader.loadClass( name );
        }
        catch (ClassNotFoundException notFound)
        {
            return null;
        }
        catch (NoClassDefFoundError notFound)
        {
            return null;
        }
    }
193872
static Class<?> findClassFromClassLoaders(final String className, final Iterable<ClassLoader> classLoaders)
        throws ClassNotFoundException, IllegalArgumentException {
        // Precondition checks
        assert className != null && className.length() > 0 : "Class Name must be specified";
        assert classLoaders != null : "ClassLoaders as search path must be specified";

        // Find the class by searching through the CLs in order
        Class<?> clazz = null;
        for (final ClassLoader cl : classLoaders) {
            try {
                clazz = Class.forName(className, false, cl);
                if (log.isLoggable(Level.FINER)) {
                    log.finer("Found requested class " + clazz.getName() + " from ClassLoader "
                        + clazz.getClassLoader());
                }
            } catch (final ClassNotFoundException cnfe) {
                // Ignore here, try the next
            }

        }
        // If we haven't got a class yet, now we need to show we've got CNFE
        if (clazz == null) {
            throw new ClassNotFoundException("Could not find requested class \"" + className
                + "\" in any of the associated ClassLoaders: " + classLoaders);
        }

        // Return
        return clazz;
    }
566315
public Class<?> loadClass(String name) throws ClassNotFoundException {
        while (true) {
            try {
                if (mClassLoader == null) {
                    return Class.forName(name);
                } else {
                    return mClassLoader.loadClass(name);
                }
            } catch (ClassNotFoundException e) {
                int index = name.lastIndexOf('.');
                if (index < 0) {
                    throw e;
                }

                // Search for inner class.
                name = name.substring(0, index) + '$' +
                        name.substring(index + 1);
            }
        }
    }
886623
private static Object newInstance(String className,
                                      ClassLoader classLoader)
        throws SOAPException
    {
        try {
            Class spiClass;
            if (classLoader == null) {
                spiClass = Class.forName(className);
            } else {
                spiClass = classLoader.loadClass(className);
            }
            return spiClass.newInstance();
        } catch (ClassNotFoundException x) {
            throw new SOAPException(
                "Provider " + className + " not found", x);
        } catch (Exception x) {
            throw new SOAPException(
                "Provider " + className + " could not be instantiated: " + x,
                x);
        }
    }
873638
private Class<?> loadClass(final String classname) throws PluginException {
        if (null == classname) {
            throw new IllegalArgumentException("A null java class name was specified.");
        }
        if (null != classCache.get(classname)) {
            return classCache.get(classname);
        }
        CachedJar cachedJar1 = getCachedJar();

        debug("loadClass! " + classname + ": " + cachedJar1.getCachedJar());
        final Class<?> cls;
        final URLClassLoader urlClassLoader = cachedJar1.getClassLoader();
        try {
            cls = Class.forName(classname, true, urlClassLoader);
            classCache.put(classname, cls);
        } catch (ClassNotFoundException e) {
            throw new PluginException("Class not found: " + classname, e);
        } catch (Throwable t) {
            throw new PluginException("Error loading class: " + classname, t);
        }
        return cls;
    }
826171
public static Object newInstance(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
		if (SIMPLE_MODE) return Class.forName(className).newInstance();

		// instantiate a temporary dummy object and get its context class loader
		ClassLoader classLoader = new ClassLoaderFinder().getContextClassLoader();
		
		Class clazz;
		if (classLoader == null) {
			LOG.debug("No context class loader found");
			clazz = Class.forName(className);
		} else {
		  LOG.debug("Context class loader found");
			try {
				clazz = classLoader.loadClass(className);
			} catch (ClassNotFoundException ex) {
				if (FALL_BACK) { 
					// Fall back to current classloader (e.g. interactive eclipse invocation)
				  LOG.debug("Fall back to current classloader");
					classLoader = ClassLoaderUtil.class.getClassLoader();
					clazz = classLoader.loadClass(className);
				} else {
					throw ex;
				}
			}
		}
		return clazz.newInstance();
	}
40605
private void createClassLoader() {
        if (!Utils.isNullOrEmpty(settings.getJarFiles())) {
            try {
                String[] files = settings.getJarFiles().split(";");
                List<URL> urls = newArrayList();
                for (String path : files) {
                    File file = new File(path);
                    if (file.isFile()) {
                        urls.add(file.toURI().toURL());
                    }
                }
                classLoader = new Java4CppClassLoader(urls.toArray(new URL[files.length]), classLoader);
            } catch (Exception e) {
                throw new RuntimeException("Failed to load jar " + e.getMessage());
            }
        }
    }
744875
@Override
    public JavaClass loadClass(String className) throws ClassNotFoundException {
        if (className.length() == 0) {
            throw new IllegalArgumentException("Request to load empty class");
        }
        className = ClassName.toSlashedClassName(className);
        ClassDescriptor classDescriptor = DescriptorFactory.instance().getClassDescriptor(className);
        try {
            return Global.getAnalysisCache().getClassAnalysis(JavaClass.class, classDescriptor);
        } catch (CheckedAnalysisException e) {
            throw new ClassNotFoundException("Exception while looking for class " + className, e);
        }
    }
1188761
static Object newInstance (ClassLoader classLoader, String className)
        throws ClassNotFoundException, IllegalAccessException,
            InstantiationException
    {
        Class driverClass;
        if (classLoader == null) {
            driverClass = Class.forName(className);
        } else {
            driverClass = classLoader.loadClass(className);
        }
        return driverClass.newInstance();
    }
589352
private Class<?> loadClass(final ClassLoader lastLoader, final String className) {
        // XXX: this is overly complicated
        Class<?> clazz;
        if (lastLoader != null) {
            try {
                clazz = lastLoader.loadClass(className);
                if (clazz != null) {
                    return clazz;
                }
            } catch (final Throwable ignore) {
                // Ignore exception.
            }
        }
        try {
            clazz = LoaderUtil.loadClass(className);
        } catch (final ClassNotFoundException | NoClassDefFoundError e) {
            return loadClass(className);
        } catch (final SecurityException e) {
            return null;
        }
        return clazz;
    }
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;
  }
671192
public static Class<?> getClass(String classname) {
		Class<?> clazz = null;
		try {
			clazz = Class.forName(classname);

		} catch (Exception e) {
			// Try the second approach
		}
		if (null == clazz) {
			Exception classNotFoundEx = null;
			try {
				clazz = Class.forName(classname, true, new ClassLoaderResourceUtils().getClass().getClassLoader());
			} catch (Exception e) {
				// Try the third approach
				classNotFoundEx = e;
			}
			if (null == clazz) {
				ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
				if (null != threadClassLoader) {
					try {
						clazz = Class.forName(classname, true, threadClassLoader);
					} 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);
					}
				} else {
					throw new BundlingProcessException(classNotFoundEx.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: "
							+ classNotFoundEx.getClass().getName() + ":" + classNotFoundEx.getMessage(),
							classNotFoundEx);
				}

			}
		}
		return clazz;
	}
790705
public static Class forName(String className, ClassLoader loader) {
        try {
            return loader.loadClass(className);
        } catch (ClassNotFoundException e) {
            if (aliasClassMap.containsKey(className)) {
                return aliasClassMap.get(className);
            }

            throw new BeanMappingException("forName class[" + className + "] is error!", e);
        }
    }
237273
SchemaFactory createInstance( String className ) {
        try {
            if (debug) debugPrintln("instantiating "+className);
            Class clazz;
            if( classLoader!=null )
                clazz = classLoader.loadClass(className);
            else
                clazz = Class.forName(className);
            if(debug)       debugPrintln("loaded it from "+which(clazz));
            Object o = clazz.newInstance();

            if( o instanceof SchemaFactory )
                return (SchemaFactory)o;

            if (debug) debugPrintln(className+" is not assignable to "+SERVICE_CLASS.getName());
        }
        // The VM ran out of memory or there was some other serious problem. Re-throw.
        catch (VirtualMachineError vme) {
            throw vme;
        }
        // ThreadDeath should always be re-thrown
        catch (ThreadDeath td) {
            throw td;
        }
        catch (Throwable t) {
            debugPrintln("failed to instantiate "+className);
            if(debug)   t.printStackTrace();
        }
        return null;
    }
1342280
public static Object loadInstance(Class clazz) throws ClassException {
	try {
	    return clazz.newInstance();
	}
	catch (InstantiationException e) {
	    throw new ClassException("the specified class object [" + clazz.getName() + "()] cannot be instantiated");
	}
	catch (IllegalAccessException e) {
	    throw new ClassException("can't load class because the currently executing method does not have access to the definition of the specified class");
	}
    }
818178
@SuppressWarnings("unchecked")
	public static <T> Class<T> loadClass(String className, boolean isInitialized) {
		return (Class<T>) ClassLoaderUtil.loadClass(className, isInitialized);
	}