/** * This method provides a readable classname if it's an array, i.e. either the classname of the * component type for arrays of java reference types or the name of the primitive type for arrays * of java primitive types. Otherwise, it returns null. */ public static String getArrayClassName(String name) { String className = null; if (name.startsWith("[")) { int index = name.lastIndexOf("["); className = name.substring(index, name.length()); if (className.startsWith("[L")) { className = className.substring(2, className.length() - 1); } else { try { Class<?> c = Class.forName(className); className = c.getComponentType().getName(); } catch (ClassNotFoundException e) { // Should not happen throw new IllegalArgumentException("Bad class name " + name, e); } } } return className; }