Esempio n. 1
0
 public static Class<?> forName(String className, ClassLoader loader) {
   try {
     return Class.forName(className, true, loader);
   } catch (ClassNotFoundException e) {
     LuiLogger.error(e.getMessage(), e);
     throw new LuiRuntimeException("构造类出错," + e.getMessage());
   }
 }
Esempio n. 2
0
 public static <T> T newInstance(Class<T> c, Class[] params, Object[] values) {
   try {
     Constructor<T> cs = c.getConstructor(params);
     return cs.newInstance(values);
   } catch (Exception e) {
     LuiLogger.error(e.getMessage(), e);
     throw new LuiRuntimeException(e.getMessage());
   }
 }
Esempio n. 3
0
 public static <T> T newInstance(Class<T> c) {
   try {
     return c.newInstance();
   }
   // catch all, include nullpointer
   catch (Exception e) {
     LuiLogger.error(e.getMessage(), e);
     throw new LuiRuntimeException(e.getMessage());
   }
 }
Esempio n. 4
0
 public static Class<?> forName(String className) {
   try {
     ClassLoader loader = LuiClassUtil.class.getClassLoader();
     Class<?> clazz = loader.loadClass(className);
     return clazz;
   } catch (ClassNotFoundException e) {
     LuiLogger.error(e.getMessage(), e);
     throw new LuiRuntimeException("没有加载到类:" + className);
   }
 }