List of utility methods to do Class Load
Class | classForName(final String className) class For Name return classForName(className, false);
|
Class> | classForName(final String clsName) class For Name if ("int".equals(clsName)) return int.class; if ("boolean".equals(clsName)) return boolean.class; return Class.forName(clsName); |
Class> | classForName(final String theClassName) Returns the class for a name. return Class.forName(theClassName);
|
Class> | classForName(String className) Class.forName() cannot instantiate Class objects for primitive data types like `int'. if (className.equals("byte")) { return byte.class; } else if (className.equals("short")) { return short.class; } else if (className.equals("int")) { return int.class; } else if (className.equals("long")) { return long.class; ... |
Class> | classForName(String className) class For Name try { return Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Exception ignore) { try { return Class.forName(className); } catch (Exception e) { throw new IllegalArgumentException("classForName(" + className + ") with ex:", e); |
Class | classForName(String className) Invokes Class#forName(String) for the given type name but does not throw any Exception . Class<T> retval = null; try { Class<?> forName = Class.forName(className); retval = (Class<T>) forName; } catch (Exception e) { return retval; |
Class> | classForName(String className) class For Name Thread t = Thread.currentThread();
ClassLoader cl = t.getContextClassLoader();
Class<?> cls = cl.loadClass(className);
return cls;
|
Class | classForName(String className) Tries to load the class with the current context class loader, and only then with the current defining class loader. try { return Class.forName(className, true, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { ; } catch (SecurityException e) { ; return Class.forName(className); ... |
Class> | classForName(String className) Method classForName try { return Class.forName(className); } catch (ClassNotFoundException e) { return null; |
Class | classForName(String className) class For Name Class c = __primitiveTypes.get(className); if (null != c) return c; try { return (Class<T>) Class.forName(className); } catch (ClassNotFoundException e) { throw new Exception(e); |