Java Utililty Methods Class Load

List of utility methods to do Class Load

Description

The list of methods to do Class Load are organized into topic(s).

Method

ClassclassForName(String className)
Tries to load a class with more classloaders.
try {
    return Class.forName(className);
} catch (ClassNotFoundException cnfe) {
    try {
        Thread thread = Thread.currentThread();
        ClassLoader threadClassLoader = thread.getContextClassLoader();
        return Class.forName(className, false, threadClassLoader);
    } catch (ClassNotFoundException cnfe2) {
...
ClassclassForName(String className)
class For Name
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
    return Class.forName(className, true, cl);
} catch (Throwable ex) {
    try {
        Class.forName(className, true, cl);
    } catch (Exception ex2) {
    throw new RuntimeException("Failed to load class: " + className + "; " + ex.getMessage(), ex);
ClassClassForName(String className)
Class For Name
return Class.forName(className.trim());
ClassclassForName(String className, Class caller)
class For Name
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
Class rtn = null;
try {
    rtn = Class.forName(className, true, tccl);
} catch (ClassNotFoundException e) {
if (rtn == null) {
    ClassLoader callerClassLoader = caller.getClassLoader();
...
ClassclassForName(String className, Class superClass)
class For Name
try {
    return Thread.currentThread().getContextClassLoader().loadClass(className).asSubclass(superClass);
} catch (ClassNotFoundException e) {
    throw new IllegalArgumentException("Class not found: " + className, e);
ClassclassForName(String className, ClassLoader classLoader)
returns Class.forName(className, true, classLoader).
try {
    return Class.forName(className, true, classLoader);
} catch (ClassNotFoundException e) {
    throw new RuntimeException("failed to load class " + className, e);
ClassclassForName(String clazzName, ClassLoader classLoader)
class For Name
if (classLoader == null)
    return Class.forName(clazzName);
return Class.forName(clazzName, true, classLoader);
ClassclassForName(String cname)
Returns the class with the given name, or null if it's not on the path.
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
    return Class.forName(cname, true, loader);
} catch (ClassNotFoundException e) {
    return null;
ClassclassForName(String columnType)
class For Name
try {
    Class c = loadedClasses.get(columnType);
    if (c == null) {
        c = Class.forName(columnType);
        loadedClasses.put(columnType, c);
    return c;
} catch (ClassNotFoundException e) {
...
ObjectclassForName(String listener)
class For Name
if (listener == null) {
    return null;
try {
    return Class.forName(listener);
} catch (ClassNotFoundException e) {
    throw new RuntimeException(e);