List of utility methods to do Class Load
Class> | loadClass(String className, ClassLoader classLoader) load Class try { return classLoader.loadClass(className); } catch (Exception e) { throw new IllegalArgumentException("loadClass(" + className + ") with ex:", e); |
Class | loadClass(String clazz, ClassLoader cl) Load class from class name, swallowing possible ClassNotFoundException. cl = cl == null ? Thread.currentThread().getContextClassLoader() : cl; try { return cl.loadClass(clazz); } catch (ClassNotFoundException e) { return null; |
Class> | loadClass(String fqcn, Class>... classes) Loads the class via the optionally specified classes in the order of their specification, and if not found, via the context class loader of the current thread, and if not found, from the caller class loader as the last resort. return loadClass(fqcn, true, classes);
|
Class | loadClass(String h, String prefix) Load a named class. if (h.indexOf(".") < 0) h = prefix + h; try { Class handleClass = Class.forName(h); return handleClass; } catch (Exception e) { return null; ... |
Class | loadClass(String inClassName) load Class try { return (Class<T>) ClassLoader.getSystemClassLoader().loadClass(inClassName); } catch (final Exception e) { return (Class<T>) Thread.currentThread().getContextClassLoader().loadClass(inClassName); |
C | loadClass(String name) load Class return (C) ClassLoader.getSystemClassLoader().loadClass(name).newInstance();
|
Class> | loadClass(String name) Load class by name. switch (name) { case "int": return int.class; case "short": return short.class; case "char": return char.class; case "byte": ... |
Class> | loadClass(String name) load Class try { return Thread.currentThread().getContextClassLoader().loadClass(name); } catch (ClassNotFoundException e) { e.printStackTrace(); return null; |
Class> | loadClass(String name) Load the class with the given name try { return Class.forName(name); } catch (ClassNotFoundException e) { throw e; |
Class | loadClass(String name) Thanks to Max Andersen at JBOSS and Scott Stanchfield try { ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); if (!useDirectClassLoading && contextClassLoader != null) { return contextClassLoader.loadClass(name); return Class.forName(name); } catch (Exception e) { return Class.forName(name); ... |