ClassLoading { public static Class loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException { if (className == null) { throw new IllegalArgumentException("className is null"); } if (classLoader == null) { throw new IllegalArgumentException("classLoader is null"); } Class resolvedClass = (Class) PRIMITIVE_CLASS_MAP.get(className); if (resolvedClass != null) { return resolvedClass; } try { return classLoader.loadClass(className); } catch (ClassNotFoundException ignore) { } if (className.endsWith(";") && className.startsWith("L")) { String typeName = className.substring(1, className.length() - 1); return classLoader.loadClass(typeName); } if (className.charAt(0) == '[') { int count = 0; int nameLen = className.length(); while (count < nameLen && className.charAt(count) == '[') { count++; } String arrayTypeName = className.substring(count, className.length()); Class arrayType = loadClass(arrayTypeName, classLoader); return getArrayClass(arrayType, count); } if (className.endsWith("[]")) { int count = 0; int position = className.length(); while (position > 1 && className.substring(position - 2, position).equals("[]")) { count++; position -= 2; } String typeName = className.substring(0, position); Class arrayType = loadClass(typeName, classLoader); return getArrayClass(arrayType, count); } throw new ClassNotFoundException("Could not load class " + className + " from unknown classloader; " + classLoader); }  static Class loadClass(String className, ClassLoader classLoader); static Class loadClass(String className, Bundle bundle); static String getClassName(Class type); static Set<Class> getAllTypes(Class type); static Set reduceInterfaces(Set source); static Class[] reduceInterfaces(Class[] source);  }
@Test public void testLoadClass_Null() { try { ClassLoading.loadClass("org.apache.geronimo.kernel.ClassLoading", (Bundle)null); fail("Expected NullArgumentException"); } catch (IllegalArgumentException ignore) { } catch (ClassNotFoundException e) { fail("Class should have been found: " + e); } }