List of utility methods to do Class Load
Class> | loadClass(String className) load Class Class<?> clazz = null; if (className == null) { return null; try { return Class.forName(className); } catch (ClassNotFoundException e) { ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader(); if (ctxClassLoader != null) { try { clazz = ctxClassLoader.loadClass(className); } catch (ClassNotFoundException e) { return clazz; |
Class | loadClass(String className) Loads a class by its fully qualified class name. return loadClass(className, null);
|
Class> | loadClass(String className) load Class return loadClass(className, true);
|
Class | loadClass(String className) load Class Class classImpl = null; try { classImpl = Class.forName(className); } catch (ClassNotFoundException cnfe) { return classImpl; |
Class | loadClass(String className) load Class return loadClass(Thread.currentThread().getContextClassLoader(), className);
|
Class> | loadClass(String className) Loads the class with the specified name try { return Class.forName(className); } catch (ClassNotFoundException e) { throw new RuntimeException("Error loading class " + className, e); } catch (NoClassDefFoundError e) { throw new RuntimeException("Error loading class " + className, e); |
Class> | loadClass(String className) load Class ClassLoader cl = Thread.currentThread().getContextClassLoader();
return loadClass(className, cl);
|
Object | loadClass(String className) load Class Class<?> c = Class.forName(className);
return c.newInstance();
|
Class> | loadClass(String className, boolean isInitialized) load Class Class<?> clazz; try { clazz = Class.forName(className, isInitialized, getClassLoader()); } catch (ClassNotFoundException cnfe) { cnfe.printStackTrace(); throw new RuntimeException(cnfe); return clazz; ... |
Class | loadClass(String className, Class callingClass) Loads the given class using the current Thread's context class loader first otherwise use the class loader which loaded this class. ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null) { return getClassLoader(callingClass).loadClass(className); } else { return loader.loadClass(className); |