MethodDescriptor (String descriptor) { int parenth = descriptor.lastIndexOf(')'); if (descriptor.length() < 2 || parenth < 0 || descriptor.charAt(0) != '(') { throw new IllegalArgumentException("Invalid descriptor: " + descriptor); } VarType[] params; if (parenth > 1) { String parameters = descriptor.substring(1, parenth); List<String> lst = new ArrayList<>(); int indexFrom = -1, ind, len = parameters.length(), index = 0; while (index < len) { switch (parameters.charAt(index)) { case '[' -> { if (indexFrom < 0) { indexFrom = index; } } case 'L' -> { ind = parameters.indexOf(";", index); lst.add(parameters.substring(indexFrom < 0 ? index : indexFrom, ind + 1)); index = ind; indexFrom = -1; } default -> { lst.add(parameters.substring(indexFrom < 0 ? index : indexFrom, index + 1)); indexFrom = -1; } } index++; } params = new VarType[lst.size()]; for (int i = 0; i < lst.size(); i++) { params[i] = new VarType(lst.get(i)); } } else { params = VarType.EMPTY_ARRAY; } VarType ret = new VarType(descriptor.substring(parenth + 1)); return new MethodDescriptor(params, ret); }