langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java
changeset 4071 10c876d2de66
parent 3543 58b72b096bcb
child 5010 c9fd6294653a
equal deleted inserted replaced
3999:e2a905534c4b 4071:10c876d2de66
   367 
   367 
   368         public int  byteLength() {
   368         public int  byteLength() {
   369             return 3;
   369             return 3;
   370         }
   370         }
   371 
   371 
       
   372         /**
       
   373          * Get the raw value of the class referenced by this constant pool entry.
       
   374          * This will either be the name of the class, in internal form, or a
       
   375          * descriptor for an array class.
       
   376          * @return the raw value of the class
       
   377          */
   372         public String getName() throws ConstantPoolException {
   378         public String getName() throws ConstantPoolException {
   373             return cp.getUTF8Value(name_index);
   379             return cp.getUTF8Value(name_index);
   374         }
   380         }
   375 
   381 
       
   382         /**
       
   383          * If this constant pool entry identifies either a class or interface type,
       
   384          * or a possibly multi-dimensional array of a class of interface type,
       
   385          * return the name of the class or interface in internal form. Otherwise,
       
   386          * (i.e. if this is a possibly multi-dimensional array of a primitive type),
       
   387          * return null.
       
   388          * @return the base class or interface name
       
   389          */
   376         public String getBaseName() throws ConstantPoolException {
   390         public String getBaseName() throws ConstantPoolException {
   377             String name = getName();
   391             String name = getName();
   378             int index = name.indexOf("[L") + 1;
   392             if (name.startsWith("[")) {
   379             return name.substring(index);
   393                 int index = name.indexOf("[L");
       
   394                 if (index == -1)
       
   395                     return null;
       
   396                 return name.substring(index + 2, name.length() - 1);
       
   397             } else
       
   398                 return name;
   380         }
   399         }
   381 
   400 
   382         public int getDimensionCount() throws ConstantPoolException {
   401         public int getDimensionCount() throws ConstantPoolException {
   383             String name = getName();
   402             String name = getName();
   384             int count = 0;
   403             int count = 0;