jetbrick-commons/src/main/java/jetbrick/beans/ClassLoaderUtils.java
public static Class<?> loadClassEx(final String qualifiedClassName, final ClassLoader classLoader) throws ClassNotFoundException {
        Validate.notNull(qualifiedClassName, "qualifiedClassName must be not null");

        ClassLoader loader = (classLoader == null) ? getDefault() : classLoader;

        // 尝试基本类型
        if (abbreviationMap.containsKey(qualifiedClassName)) {
            String className = '[' + abbreviationMap.get(qualifiedClassName);
            return Class.forName(className, false, loader).getComponentType();
        }

        // 尝试用 Class.forName()
        try {
            String className = getCanonicalClassName(qualifiedClassName);
            return Class.forName(className, false, loader);
        } catch (ClassNotFoundException e) {
        }

        // 尝试当做一个内部类去识别
        if (qualifiedClassName.indexOf('$') == -1) {
            int ipos = qualifiedClassName.lastIndexOf('.');
            if (ipos > 0) {
                try {
                    String className = qualifiedClassName.substring(0, ipos) + '$' + qualifiedClassName.substring(ipos + 1);
                    className = getCanonicalClassName(className);
                    return Class.forName(className, false, loader);
                } catch (ClassNotFoundException e) {
                }
            }
        }

        throw new ClassNotFoundException(qualifiedClassName);
    }
public static Class<?> loadClassEx(final String qualifiedClassName, final ClassLoader classLoader) throws ClassNotFoundException {
        Validate.notNull(qualifiedClassName, "qualifiedClassName must be not null");

        ClassLoader loader = (classLoader == null) ? getDefault() : classLoader;

        // 尝试基本类型
        if (abbreviationMap.containsKey(qualifiedClassName)) {
            String className = '[' + abbreviationMap.get(qualifiedClassName);
            return Class.forName(className, false, loader).getComponentType();
        }

        // 尝试用 Class.forName()
        try {
            String className = getCanonicalClassName(qualifiedClassName);
            return Class.forName(className, false, loader);
        } catch (ClassNotFoundException e) {
        }

        // 尝试当做一个内部类去识别
        if (qualifiedClassName.indexOf('$') == -1) {
            int ipos = qualifiedClassName.lastIndexOf('.');
            if (ipos > 0) {
                try {
                    String className = qualifiedClassName.substring(0, ipos) + '$' + qualifiedClassName.substring(ipos + 1);
                    className = getCanonicalClassName(className);
                    return Class.forName(className, false, loader);
                } catch (ClassNotFoundException e) {
                }
            }
        }

        throw new ClassNotFoundException(qualifiedClassName);
    }
public static Class < ? > loadClassEx ( final String qualifiedClassName , final ClassLoader classLoader ) throws ClassNotFoundException { Validate . notNull ( qualifiedClassName , "qualifiedClassName must be not null" ) ; ClassLoader loader = ( classLoader == null ) ? getDefault ( ) : classLoader ; // 尝试基本类型 if ( abbreviationMap . containsKey ( qualifiedClassName ) ) { String className = ' ' + abbreviationMap . get ( qualifiedClassName ) ; return Class . forName ( className , false , loader ) . getComponentType ( ) ; } // 尝试用 Class.forName() try { String className = getCanonicalClassName ( qualifiedClassName ) ; return Class . forName ( className , false , loader ) ; } catch ( ClassNotFoundException e ) { } // 尝试当做一个内部类去识别 if ( qualifiedClassName . indexOf ( ' ' ) == - 1 ) { int ipos = qualifiedClassName . lastIndexOf ( ' ' ) ; if ( ipos > 0 ) { try { String className = qualifiedClassName . substring ( 0 , ipos ) + ' ' + qualifiedClassName . substring ( ipos + 1 ) ; className = getCanonicalClassName ( className ) ; return Class . forName ( className , false , loader ) ; } catch ( ClassNotFoundException e ) { } } } throw new ClassNotFoundException ( qualifiedClassName ) ; }
使用指定的 ClassLoader 去载入类.
@throws ClassNotFoundException
使用指定的 ClassLoader 去载入类 .