Dynamically loads the named class (fully qualified classname) and
creates an instance from it.
<p>
Supports the use of a dynamic initializer
(see {@link  org.gautelis.vopn.lang.DynamicInitializer}&lt;C&gt;)
328710
public C load(String className, DynamicInitializer<C> di) throws ClassNotFoundException {

        Class clazz = createClass(className);
        return createObject(className, clazz, di);
    }
969088
@Override
    @FFDCIgnore(ClassNotFoundException.class)
    public Class<?> classForName(String className)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
        {
            Tr.debug(tc, "Loading class " + className + " using classloader " + delegate);
        }
        try
        {
            return delegate.loadClass(className);
        } catch (ClassNotFoundException e)
        {
            return loadFromWeldBundleCL(className);
        }
    }
164505
static Class<?> loadViewClass(Context context, String name)
            throws ClassNotFoundException {
        return context.getClassLoader().loadClass(name).asSubclass(View.class);
    }
405896
private Service initService(String serviceName) {
        m_logger.debug("Initializing service: " + serviceName);
        try {
            @SuppressWarnings("unchecked")
            Class<Service> serviceClass = (Class<Service>) Class.forName(serviceName);
            Method instanceMethod = serviceClass.getMethod("instance", (Class<?>[])null);
            Service instance = (Service)instanceMethod.invoke(null, (Object[])null);
            instance.initialize();
            return instance;
        } catch (Exception e) {
            throw new RuntimeException("Error initializing service: " + serviceName, e);
        }
    }
121737
private static RenameHandler createInstance() {
        // log errors to System.err, as problems in static initializers can be troublesome to diagnose
        RenameHandler instance = create(false);
        try {
            // calling loadFromClasspath() is the best option even though it mutates INSTANCE
            // only serious errors will be caught here, most errors will log from parseRenameFile()
            instance.loadFromClasspath();

        } catch (IllegalStateException ex) {
            System.err.println("ERROR: " + ex.getMessage());
            ex.printStackTrace();
        } catch (Throwable ex) {
            System.err.println("ERROR: Failed to load Renamed.ini files: " + ex.getMessage());
            ex.printStackTrace();
        }
        return instance;
    }
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);
        }
    }
435569
public Class createClass(String className) throws ClassNotFoundException {
        Class clazz;
        try {
            clazz = Class.forName(className);
            return clazz;

        } 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);
        }
    }
185087
public static Class<?> loadPrimitiveClass(String name) {
		Class<?> result = null;
		if (StrUtil.isNotBlank(name)) {
			name = name.trim();
			if (name.length() <= 8) {
				result = primitiveTypeNameMap.get(name);
			}
		}
		return result;
	}
34890
Class<?> loadClass(String requestedClass, boolean initialize) throws ClassNotFoundException {
    String binaryName = requestedClass;
    while (true) {
      try {
        return Class.forName(binaryName, initialize, classLoader);
      } catch (ClassNotFoundException e) {
        if (!binaryName.contains(".")) {
          throw e;
        } else {
          binaryName = replaceLastPeriodWithDollar(binaryName);
        }
      }
    }
  }
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);
        }
    }
209286
public static Class<?> classForName(String name) throws ClassNotFoundException {
		
		ClassLoader cl = getClassLoader();
		try {
			if (cl != null) {
				return cl.loadClass(name);
			}
		} catch (ClassNotFoundException e) {
			// Ignore and try using Class.forName()
		}
		return Class.forName(name);
	}
1368431
public static <T> T newInstance(Class<?> aClass, Object... initargs) 
	throws SetupException
	{
		Class<?>[] parameterTypes = null;
		
		if(initargs != null && initargs.length > 0)
		{
			parameterTypes = new Class<?>[initargs.length];
			
			for (int i = 0; i < initargs.length; i++)
			{
				if(initargs[i] == null)
					continue; //skip
				
				parameterTypes[i] = initargs[i].getClass();
			}
		}
		
		return newInstance(aClass,parameterTypes,initargs);
	}
294089
public Class<?> loadClassFrom(String name, AbstractClassLoader first) throws ClassNotFoundException {
		// try on the system one
		try { return AppClassLoader.class.getClassLoader().loadClass(name); }
		catch (ClassNotFoundException e) { /* not found. */ }
		Class<?> c = null;
		// check it is not loaded on one of the library
		for (int i = 0; i < libs.size(); i++) {
    		AbstractClassLoader cl = libs.get(i);
    		c = cl.isLoaded(name);
    		if (c != null) return c;
    	}
    	// try with the first one
    	if (first != null) {
    		try {
    			c = first.loadClassInLibrary(name);
    			if (c != null) return c;
    		} catch (FileNotFoundException e) {
    			// not found
    		} catch (IOException e) {
    			throw new ClassNotFoundException(e.getMessage());
    		}
    	}
    	// then, try on other libraries
    	for (int i = 0; i < libs.size(); i++) {
    		AbstractClassLoader cl = libs.get(i);
    		if (cl == first) continue;
    		try {
    			c = cl.loadClassInLibrary(name);
    			if (c != null) return c;
    		} catch (FileNotFoundException e) {
    			// not found
    		} catch (IOException e) {
    			throw new ClassNotFoundException(e.getMessage());
    		}
    	}
		StringBuilder msg = new StringBuilder(512);
		msg.append("Class not found: ").append(name);
		msg.append("\r\nFrom class loader: ").append(first);
		msg.append("\r\nlibraries currently registered:");
		for (int i = 0; i < libs.size(); i++)
			msg.append("\r\n - ").append(libs.get(i).toString());
		throw new ClassNotFoundException(msg.toString());
	}

	/** Load a resource. */
	@SuppressWarnings("resource")
	public IO.Readable getResourceIO(String name, byte priority) {
		if (name.length() == 0) return null;
		if (name.charAt(0) == '/') name = name.substring(1);
		IO.Readable io = null;
    	for (int i = 0; i < libs.size(); i++) {
    		AbstractClassLoader cl = libs.get(i);
   			try { io = cl.open(name, priority); }
   			catch (IOException e) { /* ignore */ }
    		if (io != null) return io;
    	}
       	// then try on the core one
        InputStream in = AppClassLoader.class.getClassLoader().getResourceAsStream(name);
        if (in == null) return null;
        return new IOFromInputStream(in, name, Threading.getUnmanagedTaskManager(), priority);
	}
416282
public Class loadClass(String name)
    {
        try
        {
            return classLoader.loadClass( name );
        }
        catch (ClassNotFoundException notFound)
        {
            return null;
        }
        catch (NoClassDefFoundError notFound)
        {
            return null;
        }
    }
410008
public static <T> Class<T> loadClass(String className, ClassLoader classloader) {
        if(className == null) {
            throw new IllegalArgumentException("className cannot be null");
        }

        if(classloader == null) {
            throw new IllegalArgumentException("classloader cannot be null");
        }

        try {
            return (Class<T>) Class.forName(className, false, classloader);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
894663
public static <T> T newInstance(final Class<T> clazz) {
        Constructor<?>[] constructors = getAllConstructorsOfClass(clazz, true);
        if (constructors == null || constructors.length == 0) {
            return null;
        }
        Object[] initParameters = getInitParameters(constructors[0].getParameterTypes());
        try {
            @SuppressWarnings("unchecked")
            T instance = (T) constructors[0].newInstance(initParameters);
            return instance;
        } catch (Exception e) {
            log.error("newInstance", e);
            return null;
        }
    }
800257
public static Class classForName(String name) throws ClassNotFoundException {
		try {
			return Thread.currentThread().getContextClassLoader().loadClass(name);
		}
		catch (Exception e) {
			return Class.forName(name);
		}
	}