List of utility methods to do Class Load
Class> | loadClass(String name) Load class through our application classpath, plus optionally try to resolve from the additional classpath. return Class.forName(name, true, CL);
|
Class> | loadClass(String name) Loads the class with the specified name. return loadClass(name, null);
|
Class> | loadClass(String name, ClassLoader cl) First checks if name is a primitive type.
if (name.equals(void.class.getName())) { return void.class; if (name.equals(byte.class.getName())) { return byte.class; if (name.equals(short.class.getName())) { return short.class; ... |
Class | loadClass(String name, ClassLoader ldr) load Class try { return Class.forName(name, true, ldr); } catch (ClassNotFoundException e) { return null; |
Class> | loadClass(String name, ClassLoader loader) Load class or throw exception try { return loader.loadClass(name); } catch (ClassNotFoundException e) { fatal("Class " + name + " not found.", e); return null; |
Class | loadClass(String theClassName, Class theReferrer) Try loading a class first by using the context class loader or by using the classloader of the referrer class if the context classloader failed to load the class. Class clazz = null; try { clazz = loadClassFromWebappClassLoader(theClassName, theReferrer); } catch (Throwable internalException) { clazz = loadClassFromContextClassLoader(theClassName); return clazz; |
Class | loadClass(T instance) load Class if (instance != null) { return (Class<T>) instance.getClass(); return null; |
Class> | loadClassByName(final String className, final ClassLoader loader) Loads a class by name try { if (loader != null) { return Class.forName(className, true, loader); return Class.forName(className); } catch (Exception ex) { return null; |
Class> | loadClassByName(String className) Load Class by class name. try { return Class.forName(className); } catch (ClassNotFoundException e) { return Thread.currentThread().getContextClassLoader().loadClass(className); |
Class | loadClassElseThrow(final String enumType) load Class Else Throw try { return (Class<T>) loadClass(enumType); } catch (ClassNotFoundException e) { throw new RuntimeException(e); |