List of utility methods to do Class forName
Class | forName(String className) Returns the Class object associated with the class or interface with the given string name.
try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); return loader.loadClass(className); } catch (ClassNotFoundException e) { try { return Class.forName(className); } catch (ClassNotFoundException ignore) { throw e; |
Class> | forName(String className) for Name ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { return Class.forName(className, true, loader); } catch (ClassNotFoundException e) { throw new IllegalStateException("Failed to find class: " + className + " loader=" + loader, e); |
Class> | forName(String className) for Name try { return Class.forName(className); } catch (Exception e) { return null; |
Class> | forName(String className) for Name try { return Class.forName(className, true, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { } catch (SecurityException e) { return Class.forName(className); |
Class | forName(String className, Class for Name try { Class<?> loadedClass = Class.forName(className); if (!instanceOfClass.isAssignableFrom(loadedClass)) { throw new IllegalStateException( "Class " + className + " does not implement " + instanceOfClass.getName()); return (Class<T>) loadedClass; } catch (ClassNotFoundException e) { ... |
Class extends T> | forName(String className, Class for Name try { Class<?> cls = Thread.currentThread().getContextClassLoader().loadClass(className); if (superType.isAssignableFrom(cls)) { return (Class<? extends T>) cls; } else { throw new IllegalStateException(className + " is not " + superType); } catch (ClassNotFoundException e) { ... |
Class extends T> | forName(String className, Class Returns the Class object object associated with the class or interface with the given string name, which is a subclass of xface . Class<?> theCls; try { theCls = Class.forName(className); } catch (ClassNotFoundException cnfe) { throw new RuntimeException(cnfe); if (!xface.isAssignableFrom(theCls)) { throw new RuntimeException(className + " not " + xface.getName()); ... |
Class> | forName(String className, ClassLoader classLoader) for Name if (classLoader == null) { return Class.forName(className); return classLoader.loadClass(className); |
Class> | forName(String className, ClassLoader defaultClassLoader) for Name return defaultClassLoader.loadClass(className);
|
Class> | forName(String name) for Name return forName(name, null);
|