public static Class forName()

in lang/src/main/java/org/apache/shiro/lang/util/ClassUtils.java [172:211]


    public static <T> Class<T> forName(String fqcn) throws UnknownClassException {
        Class<?> clazz = THREAD_CL_ACCESSOR.loadClass(fqcn);

        if (clazz == null) {
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Unable to load class named [" + fqcn
                        + "] from the thread context ClassLoader.  Trying the current ClassLoader...");
            }
            clazz = CLASS_LANG_CL_ACCESSOR.loadClass(fqcn);
        }

        if (clazz == null) {
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Unable to load class named [" + fqcn
                        + "] from the org.apache.shiro.lang ClassLoader.  Trying the additionally set ClassLoader...");
            }
            clazz = ADDITIONAL_CL_ACCESSOR.loadClass(fqcn);
        }

        if (clazz == null) {
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Unable to load class named [" + fqcn + "] from the current ClassLoader.  "
                        + "Trying the system/application ClassLoader...");
            }
            clazz = SYSTEM_CL_ACCESSOR.loadClass(fqcn);
        }

        if (clazz == null) {
            //SHIRO-767: support for getting primitive data type,such as int,double...
            clazz = PRIM_CLASSES.get(fqcn);
        }

        if (clazz == null) {
            String msg = "Unable to load class named [" + fqcn + "] from the thread context, current, or "
                    + "system/application ClassLoaders.  All heuristics have been exhausted.  Class could not be found.";
            throw new UnknownClassException(msg);
        }

        return (Class<T>) clazz;
    }