public static String methodSignatureToString()

in src/main/java/org/apache/bcel/classfile/Utility.java [943:988]


    public static String methodSignatureToString(final String signature, final String name, final String access, final boolean chopit,
        final LocalVariableTable vars) throws ClassFormatException {
        final StringBuilder buf = new StringBuilder("(");
        final String type;
        int index;
        int varIndex = access.contains("static") ? 0 : 1;
        try {
            // Skip any type arguments to read argument declarations between '(' and ')'
            index = signature.indexOf('(') + 1;
            if (index <= 0) {
                throw new InvalidMethodSignatureException(signature);
            }
            while (signature.charAt(index) != ')') {
                final String paramType = typeSignatureToString(signature.substring(index), chopit);
                buf.append(paramType);
                if (vars != null) {
                    final LocalVariable l = vars.getLocalVariable(varIndex, 0);
                    if (l != null) {
                        buf.append(" ").append(l.getName());
                    }
                } else {
                    buf.append(" arg").append(varIndex);
                }
                if ("double".equals(paramType) || "long".equals(paramType)) {
                    varIndex += 2;
                } else {
                    varIndex++;
                }
                buf.append(", ");
                // corrected concurrent private static field acess
                index += unwrap(CONSUMER_CHARS); // update position
            }
            index++; // update position
            // Read return type after ')'
            type = typeSignatureToString(signature.substring(index), chopit);
        } catch (final StringIndexOutOfBoundsException e) { // Should never occur
            throw new InvalidMethodSignatureException(signature, e);
        }
        // ignore any throws information in the signature
        if (buf.length() > 1) {
            buf.setLength(buf.length() - 2);
        }
        buf.append(")");
        return access + (!access.isEmpty() ? " " : "") + // May be an empty string
            type + " " + name + buf.toString();
    }