@Test void testGetPrimitiveClasses() throws UnknownClassException { assertEquals(ClassUtils.forName("boolean"), boolean.class); assertEquals(ClassUtils.forName("byte"), byte.class); assertEquals(ClassUtils.forName("char"), char.class); assertEquals(ClassUtils.forName("short"), short.class); assertEquals(ClassUtils.forName("int"), int.class); assertEquals(ClassUtils.forName("long"), long.class); assertEquals(ClassUtils.forName("float"), float.class); assertEquals(ClassUtils.forName("double"), double.class); assertEquals(ClassUtils.forName("void"), void.class); assertEquals(ClassUtils.forName(boolean.class.getName()), boolean.class); assertEquals(ClassUtils.forName(byte.class.getName()), byte.class); assertEquals(ClassUtils.forName(char.class.getName()), char.class); assertEquals(ClassUtils.forName(short.class.getName()), short.class); assertEquals(ClassUtils.forName(int.class.getName()), int.class); assertEquals(ClassUtils.forName(long.class.getName()), long.class); assertEquals(ClassUtils.forName(float.class.getName()), float.class); assertEquals(ClassUtils.forName(double.class.getName()), double.class); assertEquals(ClassUtils.forName(void.class.getName()), void.class); }
public static Class forName(String fqcn) throws UnknownClassException { Class clazz = THREAD_CL_ACCESSOR.loadClass(fqcn); if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the thread context ClassLoader. Trying the current ClassLoader..."); } clazz = CLASS_CL_ACCESSOR.loadClass(fqcn); } if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the current ClassLoader. " + "Trying the system/application ClassLoader..."); } clazz = SYSTEM_CL_ACCESSOR.loadClass(fqcn); } if (clazz == null) { clazz = primClasses.get(fqcn); } if (clazz == null) { String msg = "Unable to load class named [" + fqcn + "] from the thread context, current, or " + "system/application ClassLoaders. All heuristics have been exhausted. Class could not be found."; throw new UnknownClassException(msg); } return clazz; }
ClassUtils { public static Class forName(String fqcn) throws UnknownClassException { Class clazz = THREAD_CL_ACCESSOR.loadClass(fqcn); if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the thread context ClassLoader. Trying the current ClassLoader..."); } clazz = CLASS_CL_ACCESSOR.loadClass(fqcn); } if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the current ClassLoader. " + "Trying the system/application ClassLoader..."); } clazz = SYSTEM_CL_ACCESSOR.loadClass(fqcn); } if (clazz == null) { clazz = primClasses.get(fqcn); } if (clazz == null) { String msg = "Unable to load class named [" + fqcn + "] from the thread context, current, or " + "system/application ClassLoaders. All heuristics have been exhausted. Class could not be found."; throw new UnknownClassException(msg); } return clazz; } }
ClassUtils { public static Class forName(String fqcn) throws UnknownClassException { Class clazz = THREAD_CL_ACCESSOR.loadClass(fqcn); if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the thread context ClassLoader. Trying the current ClassLoader..."); } clazz = CLASS_CL_ACCESSOR.loadClass(fqcn); } if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the current ClassLoader. " + "Trying the system/application ClassLoader..."); } clazz = SYSTEM_CL_ACCESSOR.loadClass(fqcn); } if (clazz == null) { clazz = primClasses.get(fqcn); } if (clazz == null) { String msg = "Unable to load class named [" + fqcn + "] from the thread context, current, or " + "system/application ClassLoaders. All heuristics have been exhausted. Class could not be found."; throw new UnknownClassException(msg); } return clazz; }  }
ClassUtils { public static Class forName(String fqcn) throws UnknownClassException { Class clazz = THREAD_CL_ACCESSOR.loadClass(fqcn); if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the thread context ClassLoader. Trying the current ClassLoader..."); } clazz = CLASS_CL_ACCESSOR.loadClass(fqcn); } if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the current ClassLoader. " + "Trying the system/application ClassLoader..."); } clazz = SYSTEM_CL_ACCESSOR.loadClass(fqcn); } if (clazz == null) { clazz = primClasses.get(fqcn); } if (clazz == null) { String msg = "Unable to load class named [" + fqcn + "] from the thread context, current, or " + "system/application ClassLoaders. All heuristics have been exhausted. Class could not be found."; throw new UnknownClassException(msg); } return clazz; }  static InputStream getResourceAsStream(String name); static Class forName(String fqcn); static boolean isAvailable(String fullyQualifiedClassName); static Object newInstance(String fqcn); static Object newInstance(String fqcn, Object... args); static Object newInstance(Class clazz); static Object newInstance(Class clazz, Object... args); static Constructor getConstructor(Class clazz, Class... argTypes); static Object instantiate(Constructor ctor, Object... args); static List<Method> getAnnotatedMethods(final Class<?> type, final Class<? extends Annotation> annotation); }
ClassUtils { public static Class forName(String fqcn) throws UnknownClassException { Class clazz = THREAD_CL_ACCESSOR.loadClass(fqcn); if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the thread context ClassLoader. Trying the current ClassLoader..."); } clazz = CLASS_CL_ACCESSOR.loadClass(fqcn); } if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the current ClassLoader. " + "Trying the system/application ClassLoader..."); } clazz = SYSTEM_CL_ACCESSOR.loadClass(fqcn); } if (clazz == null) { clazz = primClasses.get(fqcn); } if (clazz == null) { String msg = "Unable to load class named [" + fqcn + "] from the thread context, current, or " + "system/application ClassLoaders. All heuristics have been exhausted. Class could not be found."; throw new UnknownClassException(msg); } return clazz; }  static InputStream getResourceAsStream(String name); static Class forName(String fqcn); static boolean isAvailable(String fullyQualifiedClassName); static Object newInstance(String fqcn); static Object newInstance(String fqcn, Object... args); static Object newInstance(Class clazz); static Object newInstance(Class clazz, Object... args); static Constructor getConstructor(Class clazz, Class... argTypes); static Object instantiate(Constructor ctor, Object... args); static List<Method> getAnnotatedMethods(final Class<?> type, final Class<? extends Annotation> annotation);  }