List of utility methods to do Class Load
Class | classForName(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) { ... |
Class> | classForName(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); |
Class> | ClassForName(String className) Class For Name return Class.forName(className.trim());
|
Class | classForName(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(); ... |
Class extends T> | classForName(String className, Class class For Name try { return Thread.currentThread().getContextClassLoader().loadClass(className).asSubclass(superClass); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Class not found: " + className, e); |
Class> | classForName(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); |
Class> | classForName(String clazzName, ClassLoader classLoader) class For Name if (classLoader == null) return Class.forName(clazzName); return Class.forName(clazzName, true, classLoader); |
Class | classForName(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; |
Class | classForName(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) { ... |
Object | classForName(String listener) class For Name if (listener == null) { return null; try { return Class.forName(listener); } catch (ClassNotFoundException e) { throw new RuntimeException(e); |