}
return cpUTF8;
}
public CPNameAndType cpNameAndTypeValue(String descriptor) {
CPNameAndType cpNameAndType = (CPNameAndType) descriptorsToCPNameAndTypes
.get(descriptor);
if (cpNameAndType == null) {
int index = search(cpDescriptor, descriptor);
if(index != -1) {
return cpNameAndTypeValue(index);
}
int descriptorDomain = ClassConstantPool.DOMAIN_UNDEFINED;
int colon = descriptor.indexOf(':');
String nameString = descriptor.substring(0, colon);
String descriptorString = descriptor.substring(colon + 1);
// For some reason, descriptors which have just plain
// native types are stored in DOMAIN_NORMALASCIIZ rather
// than in DOMAIN_SIGNATUREASCIIZ. This might indicate
// that DOMAIN_SIGNATUREASCIIZ is poorly named.
boolean nativeDescriptor = true;
for (int i = 0; i < descriptorString.length(); i++) {
char currentChar = descriptorString.charAt(i);
if (Character.isLetter(currentChar)) {
if (currentChar == 'L') {
nativeDescriptor = false;
}
break;
}
}
int domain = ClassConstantPool.DOMAIN_NAMEANDTYPE;
CPUTF8 name = cpUTF8Value(nameString,
ClassConstantPool.DOMAIN_NORMALASCIIZ, true);
if (nativeDescriptor) {
// Native signatures are stored in DOMAIN_NORMALASCIIZ, not
// DOMAIN_SIGNATUREASCIIZ for some reason.
descriptorDomain = ClassConstantPool.DOMAIN_NORMALASCIIZ;
} else {
descriptorDomain = ClassConstantPool.DOMAIN_SIGNATUREASCIIZ;
}
CPUTF8 descriptorU = cpUTF8Value(descriptorString, descriptorDomain, true);
cpNameAndType = new CPNameAndType(name, descriptorU, domain, index + descrOffset);
descriptorsToCPNameAndTypes.put(descriptor, cpNameAndType);
}
return cpNameAndType;
}