List of utility methods to do Class forName
Object | forName(Class classType, String className) Creates a new instance of an object given it's class name. Class c = null; try { c = Class.forName(className); } catch (Exception ex) { throw new Exception("Can't find class called: " + className); if (!classType.isAssignableFrom(c)) { throw new Exception(classType.getName() + " is not assignable from " + className); ... |
Class | forName(final Class caller, final String className) Attempt to load the named class. final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); if (contextClassLoader != null) { try { return contextClassLoader.loadClass(className); } catch (final ClassNotFoundException cnfe) { final ClassLoader callerClassLoader = caller.getClassLoader(); ... |
Class> | forName(final String className) Returns the Class object associated with the class or interface with the given string name.
try { return Class.forName(className); } catch (final ClassNotFoundException e) { return null; |
Class | forName(final String className, final Class caller) Load the specified class. final ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader(); if (threadClassLoader != null) { try { return Class.forName(className, true, threadClassLoader); } catch (final ClassNotFoundException cnfe) { if (cnfe.getException() != null) { throw cnfe; final ClassLoader classLoader = caller.getClassLoader(); if (classLoader != null) { try { return Class.forName(className, true, classLoader); } catch (final ClassNotFoundException cnfe) { if (cnfe.getException() != null) { throw cnfe; return Class.forName(className, true, ClassLoader.getSystemClassLoader()); |
Class | forName(String className) for Name return (Class<T>) (classLoader == null ? Class.forName(className)
: Class.forName(className, true, classLoader));
|
Class> | forName(String className) Gets the Class for the className in a way that works well for extensions. return Thread.currentThread().getContextClassLoader().loadClass(className);
|
Class | forName(String className) for Name try { return (Class<T>) Class.forName(className); } catch (ClassNotFoundException e) { throw new RuntimeException(className, e); |
Class | forName(String className) for Name return forName(className, Thread.currentThread().getContextClassLoader());
|
Class | forName(String className) Safe Class.forName. Class theClass = null; try { theClass = Class.forName(className, true, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { theClass = Class.forName(className); return theClass; |
Class | forName(String className) for Name try { return Class.forName(className); } catch (ClassNotFoundException e) { e.printStackTrace(); return null; |