* stack slots it consumes, eg double=2, int=1). Unlike the call above, this does minimal unpacking
*/
public static int getArgumentSizes(String signature) {
int size = 0;
if (signature.charAt(0) != '(') {
throw new ClassFormatException("Invalid method signature: " + signature);
}
int index = 1; // current string position
try {
while (signature.charAt(index) != ')') {
byte type = Utility.typeOfSignature(signature.charAt(index));
if (type <= Constants.T_VOID) {
size += BasicType.getType(type).getSize();
index++;
} else if (type == Constants.T_ARRAY) {
int dim = 0;
do {
dim++;
} while (signature.charAt(dim + index) == '[');
TypeHolder th = getTypeInternal(signature.substring(dim + index));
size += 1;
index += dim + th.getConsumed();
} else { // type == T_REFERENCE
// Format is 'Lblahblah;'
int index2 = signature.indexOf(';', index); // Look for closing ';'
// generics awareness
int nextAngly = signature.indexOf('<', index);
if (nextAngly == -1 || nextAngly > index2) {
} else {
boolean endOfSigReached = false;
int posn = nextAngly;
int genericDepth = 0;
while (!endOfSigReached) {
switch (signature.charAt(posn++)) {
case '<':
genericDepth++;
break;
case '>':
genericDepth--;
break;
case ';':
if (genericDepth == 0) {
endOfSigReached = true;
}
break;
default:
}
}
index2 = posn - 1;
}
size++;
index = index2 + 1;
}
}
} catch (StringIndexOutOfBoundsException e) { // Should never occur
throw new ClassFormatException("Invalid method signature: " + signature);
}
return size;
}