private static Type[] makeParameterArray(String descriptor) {
    int length = descriptor.length();

    if (descriptor.charAt(0) != '(') {
      throw new IllegalArgumentException("bad descriptor");
    }

    /*
     * This is a cheesy way to establish an upper bound on the
     * number of parameters: Just count capital letters.
     */
    int closeAt = 0;
    int maxParams = 0;
    for (int i = 1; i < length; i++) {
      char c = descriptor.charAt(i);
      if (c == ')') {
        closeAt = i;
        break;
      }
      if ((c >= 'A') && (c <= 'Z')) {
        maxParams++;
      }
    }

    if ((closeAt == 0) || (closeAt == (length - 1))) {
      throw new IllegalArgumentException("bad descriptor");
    }

    if (descriptor.indexOf(')', closeAt + 1) != -1) {
      throw new IllegalArgumentException("bad descriptor");
    }

    return new Type[maxParams];
  }
Helper for {@link #intern} which returns an empty array to populate with parsed parameter
types, and which also ensures that there is a '(' at the start of the descriptor and a single
')' somewhere before the end.

@param descriptor {@code non-null;} the descriptor string
@return {@code non-null;} array large enough to hold all parsed parameter types, but which is
    likely actually larger than needed
android/android_framework/dex-maker/src/main/java/com/android/dx/rop/type/Prototype.java