Helper for executing static methods on a Class

@param className String fully qualified class
@param methodName String method name
@return Object result
@throws ClassLoaderException exception
339182
public Object execStaticMethod( String className, String methodName ) throws ClassLoaderException {
        return execStaticMethod( className, methodName, null );
    }
859533
static Class<?> loadType(String fullName) throws ClassNotFoundException {
        try {
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            return loader != null ? loader.loadClass(fullName) : Class.forName(fullName);
        } catch (ClassNotFoundException ex) {
            return loadPrimitiveType(fullName, ex);
        }
    }
575186
public final Set<RegData> load(String dirName, String className, String methodName) {
        String fullName = className + '.' + methodName;
        return load(openFileRead(dirName, fullName, className, methodName));
    }
1142344
public static Class<? extends WebPage> loadClass(String className) throws ClassNotFoundException {
		return Class.forName(className).asSubclass(WebPage.class);
	}
427764
static ClassLoader getClassLoader ()
    {
        Method m = null;

        try {
            m = Thread.class.getMethod("getContextClassLoader");
        } catch (NoSuchMethodException e) {
            // Assume that we are running JDK 1.1, use the current ClassLoader
            return NewInstance.class.getClassLoader();
        }

        try {
            return (ClassLoader) m.invoke(Thread.currentThread());
        } catch (IllegalAccessException e) {
            // assert(false)
            throw new UnknownError(e.getMessage());
        } catch (InvocationTargetException e) {
            // assert(e.getTargetException() instanceof SecurityException)
            throw new UnknownError(e.getMessage());
        }
    }
251942
static Class<?> loadClass(String className, Class<?> context, boolean checkParent)
    {
        Class<?> clazz = null;
        try
        {
            clazz = Thread.currentThread().getContextClassLoader().loadClass(className);  
        }
        catch(ClassNotFoundException e)
        {
            if(context != null)
            {
                ClassLoader loader = context.getClassLoader();
                while(loader != null)
                {
                    try
                    {                    
                        clazz = loader.loadClass(className);
                        return clazz;
                    }
                    catch(ClassNotFoundException e1)
                    {
                        loader = checkParent ? loader.getParent() : null;
                    }
                }
            }
        }
        return clazz;
    }
812712
public static Method getMethod(String clazzName, String methodName, String[] argsType) {
        Class clazz = ClassUtils.forName(clazzName);
        Class[] classes = ClassTypeUtils.getClasses(argsType);
        return getMethod(clazz, methodName, classes);
    }
681920
static Method lookupMethod(Class<?> javaClass, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException {
        if (System.getSecurityManager() != null) {
            try {
                return AccessController.doPrivileged(new MethodLookupAction(javaClass, methodName, parameterTypes));
            } catch (PrivilegedActionException e) {
                if (e.getCause() instanceof NoSuchMethodException) {
                    throw (NoSuchMethodException) e.getCause();
                }
                throw new WeldException(e.getCause());
            }
        } else {
            return MethodLookupAction.lookupMethod(javaClass, methodName, parameterTypes);
        }
    }
1118913
public static Class<?> tryLoadClass(String className) throws ClassNotFoundException {
        try {
            return Class.forName(className);
        } catch (ClassNotFoundException e) {
            ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
            return contextClassLoader.loadClass(className);
        }
    }
339151
@SuppressWarnings("unchecked")
    public static <T> Class<T> loadClass(String className) {
        return loadClass(className, ClassLoaderUtil.class.getClassLoader());
    }
409980
public synchronized Class<?> loadClass(String className) throws ClassNotFoundException {
	// if class is already loaded flush the classloader and do new classloader
	PCLBlock cl = index.get(className);
	if (cl != null) {
	    return cl.loadClass(className);
	}
	throw new ClassNotFoundException("class " + className + " not found");
    }
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);
        }
    }
1132629
public static Object invokeMethod(Object object, String methodName, Class<?>[] parameterTypes,
                                      Object[] parameters) throws NoSuchMethodException, InvocationTargetException,
            IllegalAccessException {
        if (Checker.isEmpty(parameters)) {
            return object.getClass().getMethod(methodName).invoke(object);
        } else {
            return object.getClass().getMethod(methodName, parameterTypes).invoke(object, parameters);
        }
    }
1297595
public static Class forName(String name) throws ClassNotFoundException {
		// try with caller classloader
		ClassLoader loader = getClassLoaderContextAt(3);
		try {
			return Class.forName(name, true, loader);
		} catch (ClassNotFoundException e) {
			// try with context classloader if set & different
			ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
			if (contextLoader == null || contextLoader == loader) {
				throw e;
			} else {
				return Class.forName(name, true, contextLoader);
			}
		}
	}
66325
public Method getJavaMethod(Class<?> clazz, String methodName) {
        String className = clazz.getName();
        Method[] methods = allMethodCache.get(className);
        if (methods == null) {
            initJavaClassCache(clazz);// 分析一次clazz,这时会跟新allMethodCache
            methods = allMethodCache.get(className);
        }
        if (methods == null) {
            return null;
        }

        for (Method method : methods) {
            if (methodName.equals(method.getName())) {
                return method;
            }
        }
        return null;
    }
1142840
public static Class loadClass(String className) throws ClassException {
	Set<Throwable> exceptions = new HashSet<Throwable>();
	// OSGI env
	Class clazz = _loadClass(new OSGiBasedClassLoading(), className, null, exceptions);
	if (clazz != null) {
	    return clazz;
	}

	// core classloader
	clazz = _loadClass(new ClassLoaderBasedClassLoading(SystemUtil.getCoreClassLoader()), className, null, exceptions);
	if (clazz != null) {
	    return clazz;
	}

	// loader classloader
	clazz = _loadClass(new ClassLoaderBasedClassLoading(SystemUtil.getLoaderClassLoader()), className, null, exceptions);
	if (clazz != null) {
	    return clazz;
	}

	String msg = "cannot load class through its string name, because no definition for the class with the specified name [" + className + "] could be found";
	if (exceptions.size() > 0) {
	    StringBuilder detail = new StringBuilder();
	    Iterator<Throwable> it = exceptions.iterator();
	    Throwable t;
	    while (it.hasNext()) {
		t = it.next();
		detail.append(t.getClass().getName()).append(':').append(t.getMessage()).append(';');
	    }
	    throw new ClassException(msg + " caused by (" + detail.toString() + ")");
	}
	throw new ClassException(msg);
    }
323989
public static <T> Class<T> classForName(ResourceLoader resourceLoader, String className) {
        try {
            return cast(resourceLoader.classForName(className));
        } catch (Exception e) {
            CommonLogger.LOG.cannotLoadClassUsingResourceLoader(className);
            CommonLogger.LOG.catchingTrace(e);
        }
        try {
            return cast(Class.forName(className));
        } catch (Exception | LinkageError e) {
            throw CommonLogger.LOG.cannotLoadClass(className, e);
        }
    }