1.1 --- a/src/share/classes/com/sun/tools/classfile/ConstantPool.java Mon Sep 28 16:48:30 2009 -0700 1.2 +++ b/src/share/classes/com/sun/tools/classfile/ConstantPool.java Tue Oct 13 14:02:53 2009 -0700 1.3 @@ -369,14 +369,33 @@ 1.4 return 3; 1.5 } 1.6 1.7 + /** 1.8 + * Get the raw value of the class referenced by this constant pool entry. 1.9 + * This will either be the name of the class, in internal form, or a 1.10 + * descriptor for an array class. 1.11 + * @return the raw value of the class 1.12 + */ 1.13 public String getName() throws ConstantPoolException { 1.14 return cp.getUTF8Value(name_index); 1.15 } 1.16 1.17 + /** 1.18 + * If this constant pool entry identifies either a class or interface type, 1.19 + * or a possibly multi-dimensional array of a class of interface type, 1.20 + * return the name of the class or interface in internal form. Otherwise, 1.21 + * (i.e. if this is a possibly multi-dimensional array of a primitive type), 1.22 + * return null. 1.23 + * @return the base class or interface name 1.24 + */ 1.25 public String getBaseName() throws ConstantPoolException { 1.26 String name = getName(); 1.27 - int index = name.indexOf("[L") + 1; 1.28 - return name.substring(index); 1.29 + if (name.startsWith("[")) { 1.30 + int index = name.indexOf("[L"); 1.31 + if (index == -1) 1.32 + return null; 1.33 + return name.substring(index + 2, name.length() - 1); 1.34 + } else 1.35 + return name; 1.36 } 1.37 1.38 public int getDimensionCount() throws ConstantPoolException {