class Type {
/**
* Convert arguments of a method (signature) to an array of Type objects.
* @param signature signature string such as (Ljava/lang/String;)V
* @return array of argument types
*/
public static Type[] getArgumentTypes( String signature ) {
List<Type> vec = new ArrayList<>();
int index;
Type[] types;
try { // Read all declarations between for `(' and `)'
if (signature.charAt(0) != '(') {
throw new ClassFormatException("Invalid method signature: " + signature);
}
index = 1; // current string position
while (signature.charAt(index) != ')') {
vec.add(getType(signature.substring(index)));
//corrected concurrent private static field acess
index += unwrap(consumed_chars); // update position
}
} catch (StringIndexOutOfBoundsException e) { // Should never occur
throw new ClassFormatException("Invalid method signature: " + signature, e);
}
types = new Type[vec.size()];
vec.toArray(types);
return types;
}
}